What does it mean when Spring MVC @Controller returns null view name?

If a controller returns a null view name, or declares a void return type, Spring will attempt to infer the view name from the request URL.

Up vote 2 down vote favorite share g+ share fb share tw.

I downloaded the code for the Spring MVC 3 Showcase. One thing puzzles me (well, more than one), why does this (edited for concision) sample return null? @Controller @RequestMapping("/form") public class FormController { @RequestMapping(method=RequestMethod.

POST) public String processSubmit(@Valid FormBean form, BindingResult result, WebRequest webRequest, HttpSession session, Model model) { if (result.hasErrors()) { return null; } else { session. SetAttribute("form", form); return "redirect:/form"; } } } spring-mvc link|improve this question asked Jul 29 '11 at 15:13Paul McKenzie2,569728 93% accept rate.

If a controller returns a null view name, or declares a void return type, Spring will attempt to infer the view name from the request URL. In your case, it will assume the view name is form, and proceed on that assumption. It does this using an implementation of RequestToViewNameTranslator, the default implementation of which is DefaultRequestToViewNameTranslator, the javadoc for which explains the exact rules it applies.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions