jsp - How to use form:radiobuttons with out model/command object -
I would like to use the form: the spring form tag BBB to get the input form user, but I do not want to Use the model / command object because it is the only value that I get in the form of input. So I tried it below.
JSP:
& lt; Form action = "submitform" method = "post" & gt; & Lt; Form: radiobuttons path = "lang" item = "$ {languages}" /> & Lt; Input type = "submit" value = "save" /> & Lt; / Form & gt; Administrator's method:
@RequestMapping ("submitform") Public ModelAndView submitForm (@RequestParam ("lang") list & lt; string & gt; ; Lang) {system .out.println ("test:" + lang); Return a new model and view ("Exam", "Lang", Lang); } When I submit the form, the application throws it under error HTTP status 400 - The required list parameter 'Lang' does not exist.
Can someone tell me the correct way to do this, I have two requirements below
1. To use the form: Radiobuttons
2. Do not want to use the model / order object.
Please help
How to use the form: Radiogotone out model With / Command Object
You can not use the form of spring elements, without the support of the bean. For the data binding of the path attribute of the form element of spring, it is assumed to specify the path of the model / command bean's property. About Spring javadoc & lt; Form: Radiobuttons : | Feature | Necessary? | Sequence expression? | description ------------------------------------------------- ----------- | Path | True | The path to the property for correct binding This means, in your case, when you do not have the model / command line for data binding, then throw an exception with the spring message: < Can anyone tell me the correct way to do this
Use simple HTML radio boots in jsp and make it your own. Keep it in all ways. Renders such as Redboot into JSP:
& lt; Form action = "submit" method = "post" & gt; & Lt;% - & lt; Form: radiobuttons path = "lang" items = "$ {languages}" /> -% & gt; & Lt; C: forEach item = "$ {languages}" var = "lng" & gt; & Lt; Input type = "radio" name = "lang" value = "$ {lng}" & gt; $ {Lng} & lt; / C: forEach & gt; & Lt; Input type = "submit" value = "save" /> & Lt; / Form & gt;
Comments
Post a Comment