Spring MVC - passing variables from one page to anther

后端 未结 3 1515
野的像风
野的像风 2020-12-19 17:01

I need help. I am working on a project where I have multiple pages and multiple forms; each page has one form. I just need to be able to pass values from one jsp to another.

3条回答
  •  半阙折子戏
    2020-12-19 17:22

    You have to persist the user entered information on the first page either using a hidden variable as mentioned above by JB Nizet. Or you can set the value in the model attribute that will be returned on your corresponding controllers.

    The pseudo code for you.

    formPage1.jsp --> Controller1 --> set the values in this form by retrieving it from the Request object --> formPage2a.jsp --> Controller2 will have val frm both pg1 & pg2a.

    In this way there is no need to maintain a session attribute.

提交回复
热议问题