在Struts2中,可以使用EL表达式(Expression Language)来显示Action中的数据。
首先,在JSP页面中导入Struts2标签库:
<%@taglib prefix="s" uri="/struts-tags"%> 然后,使用EL表达式来显示Action中的数据:
<s:property value="propertyName" /> 其中,propertyName是Action中的属性名。
示例:
假设有一个名为UserAction的Action类,其中有一个名为username的属性,可以在JSP页面中使用EL表达式来显示该属性的值:
<s:property value="username" /> 这样,页面就会显示UserAction中的username属性的值。