I am using Spring 3.0.6
, and have noted a few (apparently) contradictory statements regarding what happens when a controller method declares a void return type (or returns a null). Consider the following :
@Controller
@RequestMapping(value="admin/*")
public class AdminController {
@RequestMapping
public ResponseEntity<String> hello() {
System.out.println("hellooooooo");
}
}
This takes the view name as the method name as stated here. But as stated in the accepted answer here, the view name is derived from url (not the method name). The method in question was :
@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";
}
}
}