Calling static method helper class in Struts2 JSP with Action data model value

前端 未结 2 1742
刺人心
刺人心 2020-12-21 04:50

I\'m a Struts2 newbie. I\'m using Struts2 with the typical datamodel UserItem inside an Action. The datamodel doesn\'t look good when using with the Struts ta

2条回答
  •  别那么骄傲
    2020-12-21 05:29

    For Static Method Access you must need to add following constant in your struts.xml file.

     
    

    Example: struts.xml:

    
    
    
        
        
            
                /WEB-INF/JSP/sample.jsp
                 
        
    
    

    Then from your JSP you can access it in various ways:

    Example - 1:

    Output :  

    Where,

    1. vaannila = Package Name.
    2. SampleAction = Class Name.
    3. getSTR() = Method Name.

    Example - 2:

    Output :  

    Where,

    1. vs = Value Stack.
    2. getSTR() = Method Name.

    Example - 3:

    Output :  

    where,

    1. STR = STR is declared and initialized as Static String with getter and setter method in your Java Class

提交回复
热议问题