I’ve added a new method/mapping to one of my servlets:
@RequestMapping(value = "/user/prefs/order", method = RequestMethod.POST)
public void updateUsersPrefs(@RequestBody Map<String, ArrayList> body, HttpServletRequest request) {
...
}
but when I send a request to this url I get a 500 Internal Server Error, with the following error message:
javax.servlet.ServletException: Could not resolve view with name 'user/prefs/order' in servlet with name 'appfinder'
org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1029)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:817)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
I cannot for the life of me see why this is being reported. Can anyone help with this? I there is anymore information that I could provide, please let me know.
Thanks!
Spring treats
@RequestMappingmethods withvoidreturn type in the following manner:Therefore since there is no
HttpServletResponseparameter to this method, Spring assumes that you would like the view name to be determined through aRequestToViewNameTranslator.If you do not specify a particular
RequestToViewNameTranslatorto use in your context, then the default implementation kicks in which will:If you don’t want the URI of the incoming request to be used as the view name, you have a few options:
RequestToViewNameTranslatorwith the behavior you would likeHttpServletResponseparameter to this method if you would like to write to the response directly rather than View resolution take place.String,View, orModelAndView` to be able to specify the view or view name within the method.