passing value of checkbox in spring to next page -


First Page Controller, I passed checkbok Post method,

  @RequestMapping ( value = { "/new.html"}, method = {RequestMethod.POST}) public ModelAndView submitNew (last HttpServletRequest request, @RequestParam (value = "asSelectedCheckbox", = false) requires Boolean asSelectedCheckbox) { < / Pre> 

I have also passed the checkbox received from the law, and then in the post method, if I did say to show that the checkbox is correct, but the request is always the second page Gives wrong Rt controller, no matter if it went to check the box or not

The second page POST method controller

  @RequestMapping (value = { "/ newNext.html "}, method = {RequestMethod.POST}) public ModelAndView submitNewNext (last HttpServletRequest request, @RequestParam (value =" asSelectedCheckbox ", required = false) Boolean asSelectedCheckbox) { 

My first page checkbox

  & lt; Input Id = "id" name = "checkbox selected as type" type = "checkbox" />  

How can I pass the correct value of the checkbox from the first page to the next?

Each time the controller is called the new "run" of your program, in which the state is not And before that nobody knows about who told it.

What would be the case if two users opened new html at once and a form submitted with checkbox was checked, and without any other? How to treat your newNext.html then

Now the answer:

You are bound to a specific user, or in the passed session to see either the store checkbox price , So that when newNext .html is being submitted you get that value.

You can add and submit the following code ():

  model.add (elected as "Cheksboks", the Cheksboks) selected as ;  

After code in new.jsp:

   

And the following code at the top of new.jsp:

  & lt;% @ taglib prefix = "form" Yuri = "http: // www .springframework.org / Tag / Form "%"  

Comments