在Struts 2中动态生成名称和值属性 [英] Generate name and value attribute dynamically in Struts 2

查看:52
本文介绍了在Struts 2中动态生成名称和值属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将代码从Struts1迁移到Struts2

I am migrating the code from Struts1 to Struts2

<input type="text" value="<c:out value="${serviceVO.notifList}"/>" name="ServicesNotifList-<c:out value="${serviceVO.globalId}"/>#<c:out value="${serviceVO.id}"/>" size="50" maxlength="1000"/>

在Struts2中

我尝试了但没用

in Struts2

I tried but not working

<c:set var="notifListTemp" value="ServicesNotifList-"></c:set>
<c:set var="notifListTemp1" >${notifListTemp}${serviceVO.globalId}</c:set>
<c:set var="notifListTemp2" value="#"></c:set>
<c:set var="notifListTemp3" >${notifListTemp1}${notifListTemp2}${serviceVO.id}</c:set>

<s:textfield theme="simple" value="${serviceVO.notifList}" name="${notifListTemp3}" 
 size="50" maxlength="1000"  />

其中serviceVOdisplay:table id.

推荐答案

您不能在Struts标记的属性中使用JSP EL表达式,但是很高兴您可以使用OGNL表达式.通过#attr访问的不在值堆栈中的对象.

You can't use JSP EL expressions in Struts tag's attributes, but happily you can use OGNL expressions. Objects that are not in the value stack accessed via #attr.

<s:textfield theme="simple" value="%{#attr.serviceVO.notifList}" name="%{#attr.notifListTemp3}" 
     size="50" maxlength="1000"  />

这篇关于在Struts 2中动态生成名称和值属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆