I am using MyEclipse to generate a CRUD Application with REST service , the web CRUD application is well generated and working fine , but i want use also the REST service , the RestControler generated is like that :
@Controller("NewsRestController")
public class NewsRestController {
/**
* DAO injected by Spring that manages News entities
*
*/
@Autowired
private NewsDAO newsDAO;
/**
* Service injected by Spring that provides CRUD operations for News entities
*
*/
@Autowired
private NewsService newsService;
/**
* Create a new News entity
*
*/
@RequestMapping(value = "/News", method = RequestMethod.POST)
@ResponseBody
public News newNews(@RequestBody News news) {
newsService.saveNews(news);
return newsDAO.findNewsByPrimaryKey(news.getId());
}
/**
* Show all News entities
*
*/
@RequestMapping(value = "/News", method = RequestMethod.GET)
@ResponseBody
public List<News> listNewss() {
return new java.util.ArrayList<News>(newsService.loadNewss());
}
i tried to call this service using this url :
http://localhost:8080/JPO/NewsRestController/News
i use Postman to test this REST service , i could not get any response. what can be the problem ?
http://localhost:8080/JPO//Newsin postman, selectGetmethod, and you'd better declare a new path for the get mapping.