Spring MVC 3 - How come @ResponseBody method renders a JSTLView?

Posted by Ken Chen on Stack Overflow See other posts from Stack Overflow or by Ken Chen
Published on 2010-06-08T14:45:57Z Indexed on 2010/06/09 7:12 UTC
Read the original article Hit count: 273

Filed under:
|
|

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?

© Stack Overflow or respective owner

Related posts about java

Related posts about spring