Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试使用Struts2访问jsp中动作类的方法中定义的变量的值。我在动作类的方法中定义了一个变量 desc_map。我想在 jsp 中访问 this 的值。我该怎么做?谢谢你。
为属性创建一个公共 getter,最好按照 JavaBean 规范正确命名:
public TheType getDescMap() { return desc_map; }
从 JSP 访问它:
${descMap}
或者如果您需要转义,则不能使用 JSP 2.0+ 等:
<s:property value="descMap"/>
所有这些基本上都包含在每个 Struts 2 教程中。