The struts2 value is stored in valuestack. Suppose there is a string 'str', which is generally the value:
<S: property value = "str"/> or $ {STR}
If you want to use it in JSP, you can use the following:
<%@ PageImport="Com. opensymphony. xwork2.util. valuestack" %>
......
<% =(Valuestack) request. getattribute ("Struts. valuestack"). Findstring ("Str")%>
You can also put the value in valuestack into attribute first, and then directly take the value of attribute:
<S: Set Name="Str"Value="% {STR}" />
<% =Request. getattribute ("Str")%>
Call a function on the struts2 page
Method 1:
<S: Set Name = "str" value = "'Hello world'"> </S: Set>
<S: property value = "% {@ com. Common. Constant @ func (# Str)}"/>
Func is a static method in COM. Common. Constant.
STR is a dynamic parameter
Method 2:
<S: bean name = "com. Common. strutshelper" id = "helper"/>
<S: Set Name = "str" value = "'Hello world'"> </S: Set>
<S: property value = "# helper. func (# Str)"/>
Func is a common method in COM. Common. strutshelper.
STR is a dynamic method
S: bean is actually an instantiation of the strutshelper class, which is somewhat different from method 1. The function in method 1 must be static.