I have mapped one of my method in one Controller to return JSON object by @ResponseBody.
@RequestMapping("/{module}/get/{docId}")
public @ResponseBody Map<String, ? extends Object> get(@PathVariable String module,
@PathVariable String docId) {
Criteria criteria = new Criteria("_id", docId);
return genericDAO.getUniqueEntity(module, true, criteria);
}
However, it redirects me to the JSTLView instead. Say, if the {module} is product and {docId} is 2, then in the console I found:
DispatcherServlet with name 'xxx' processing POST request for [/xxx/product/get/2]
Rendering view [org.springframework.web.servlet.view.JstlView: name 'product/get/2'; URL [/WEB-INF/views/jsp/product/get/2.jsp]] in DispatcherServlet with name 'xxx'
How can that be happened? In the same Controller, I have another method similar to this but it's running fine:
@RequestMapping("/{module}/list")
public @ResponseBody Map<String, ? extends Object> list(@PathVariable String module,
@RequestParam MultiValueMap<String, String> params,
@RequestParam(value = "page", required = false) Integer pageNumber,
@RequestParam(value = "rows", required = false) Integer recordPerPage) {
...
return genericDAO.list(module, criterias, orders, pageNumber, recordPerPage);
}
Above do returns correctly providing me a list of objects I required.
Anyone to help me solve the mystery?