I am learning Spring MVC, and I searched everywhere to make only the base controller to view the data binding, but tried nothing to work. I can associate viewing the declaration back with the controller, and I can see pojo with the properties there, however whenever I try to add this object to the model, I get nothing. Here is what I still have:
controller
@Controller public class HomeController { @RequestMapping(value = "/", method = RequestMethod.GET) public String home(Model model) { model.addAttribute(new Person()); return "home"; } @RequestMapping(value="/about", method=RequestMethod.POST) public void about(Person person, Model model) { model.addAttribute("person", person); } }
Class I want to bind
public class Person { private String _firstName; private String _lastName; private Date _Birthday;
View - controller-to-form! Working
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> <html> </head> <body> FirstName: ${model.person.getFirstName} LastName: ${model.person.getLastName} </body> </html>
What do I need or need to do to tie it?
Kai CriticallyAcclaimed Cooper
source share