如何分配 <s:property value="a">一个jsp变量的值

2022-01-16 00:00:00 java jsp struts2

谁能告诉如何将来自 "<s:property value="a">" 的值分配给 jsp 变量?

Can anybody tell how to assign a value coming from "<s:property value="a">" into jsp variable ?

推荐答案

您可以为此使用 s:set 标签.

You can use the s:set tag for this.

例如,这将从您的操作中调用 getA() 并将值放入avalue",不要使用 name 代替 var

For example this will call getA() from your action and put the value into "avalue", don't use name instead of var

<s:set var="avalue" value="a" />

然后你可以像在 JSP 上这样引用它:

And then you can reference it like so on the JSP:

<b>Print value defined in set tag :</b> <s:property value="#avalue" /> <br/>

这将打印出值.

相关文章