开发者

how to pass an object value to 2 jsp pages via spring controller

i have 2 model class

public class Abcd {

    private String name;
    private String familyName;

// getters and setters
}

public class Bcd {

    private String color;

// getters and setters
开发者_开发知识库}

i want that 1st jsp page takes input for Abcd, and then pass it to 2nd jsp page, where i also take input for the BCD class and then i show both objects input data to the 3rd page

please suggest the way to do this


You could put the Abcd's name and family in hidden fields on the second page. The action calling the third page would be able to access to Abcd's and Bcd's attributes and show them in the third JSP.


You can put this object into one object:

public class Wizard {
   private Abcd first;
   private Bcd  second;

    // setters, gettes
}

Then in your controller put: @SessionAttribute("wizard") public class WizardController {

@ModelAttribute("wizard")
public Wizard modelWizar() {
  return new Wizard();
}

}

For more information go to Spring reference http://static.springsource.org/spring/docs/3.0.5.RELEASE/spring-framework-reference/html/mvc.html#mvc-ann-sessionattrib

If you are using Spring version < 2.5 then you can use

AbstractWizardFormController which is deprecated in newest version of spring.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜