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

查看:31
本文介绍了在 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天全站免登陆