Struts 2 : Unable to access Model properties in JSP

后端 未结 2 764
深忆病人
深忆病人 2021-01-28 04:51

I have problem with accessing Model properties (ProcessSolution) in my JSP , I\'m not getting what is wrong with my following codes :

This is my model Class

相关标签:
2条回答
  • 2021-01-28 05:41

    You need to change your result type of your action to dispatch in your ProcessSolutionAction in struts.xml.

    Sample:

    <result name="success" type="dispatcher">sample.jsp</result>
    

    or you remove the type on your result because the default value of type is dispatcher

    <result name="success">sample.jsp</result>
    

    Maybe your result type is redirect that's why you can't take a value on your action class to your jsp.

    0 讨论(0)
  • 2021-01-28 05:49

    When you use ModelDriven interface, the model type should be initialized in the action. In your case, change ProcessSolutionAction, line:

    private ProcessSolution processSolution;
    

    to

    private ProcessSolution processSolution = new ProcessSolution();
    

    Initializing the model type in prepare() method is not applicable with ModelDriven because they are invoked from two different interceprtors. And Model Driven Interceptor must become first. Here is some documentation: Model Driven Interceptor

    0 讨论(0)
提交回复
热议问题