Monday 15 June 2015

java - how to connect form values in jsp to controller in spring MVC -


I'm new to spring MVC I want to add a model bean in a form that binds the values ​​and The administrator passes up so I did the following way

jsp

  & lt; Form: form modelattribute = "model" & gt; & Lt; Form: Input path = "var1" /> & Lt; / Form: Form & gt;   

In the controller

  unbridged method (@modeltibbrid ("model") bean bean) {// my code}   

But when entering the form, it represents JSP when throwing it as an exception in the form of an exception, such a bean name does not exist with model

how to solve it Do you?

Suppose your model class looks like this:

 < Code> Public class MyMold {Private String Propane; Private string porporto;  
  Use  @ModelAttribute  to map the URL to your form bean  
  @ReveParam ("/ myPage") Public string myController (@ModelAttribute MyModel myModel) {/ * Your processing is here / /   

On the jsp page, just type your input field to Name (HTML Attribute: Name) to map the properties inside the bean:

  & lt; Form: input name = "propOne" class = "xyz" /> & Lt; Appearance: Input Name = "Propotu" class = "XIs" />   

This completes your bean mapping.

No comments:

Post a Comment