【问题标题】:Generate name and value attribute dynamically in Struts 2在 Struts 2 中动态生成名称和值属性
【发布时间】:2014-12-22 05:52:54
【问题描述】:

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

Struts1 代码

<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 中

我试过了,但没用

<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。

【问题讨论】:

    标签: jsp struts2 jstl struts ognl


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-29
      • 2014-10-18
      • 1970-01-01
      • 1970-01-01
      • 2016-03-12
      • 2011-06-29
      相关资源
      最近更新 更多