I'm trying to convert some code from Spring 2.* to 4.3.
How would I write the bellow code with annotations? I'm having trouble getting my head around the documentation.
import org.springframework.web.portlet.mvc.SimpleFormController;
public class SearchController extends SimpleFormController {
public SearchController () {
this.setFormView("edit-search");
this.setSuccessView("edit-search");
this.setCommandClass(ListWrapper.class);
this.setCommandName("aList");
this.setSessionForm(false);
}
You can do something like this:
@Controller // instead of extending SimpleFormController
@RequestMapping("/yourFile.htm")
public class SearchController {
@RequestMapping(method=RequestMethod.POST) // here I have added as Post as HTTP method as a sample.
public void SearchController(@ModelAttribute("aList")/* commandName */ ListWrapper listWrapper/*CommandClass*/){
if(some Errors|| null validation fails){
return "edit-search";// formView
}
return "edit-search";// successView
}
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments