簡體   English   中英

帶有struts的html和jsp scriptlet中的串聯挑戰

[英]concatenation challenge in html and jsp scriptlets with struts

<script>
   var myValue = ${valueBean};
</script>

myValue的值為5

<input type="text" name="<%=curName%>'[' + myValue +'].otherList[' + myValue + '].'<%=curProp%>" value="<%=(String) currentItr.next()%>"/>

當我查看源代碼時,生成的html一直在給我

<input type="text" name="myList'[' + myValue +'].otherList[' + myValue + '].'someProp" value="XXX"/>

什么時候應該

<input type="text" name="myList[5].otherList[5].someProp" value="XXX"/>

我在做其他事情嗎,我看不到串聯問題在哪里。 請幫忙!

除了使用myValue之外,您還可以使用jstl和使用jstl c:out標記直接嵌入的valueBean

name="myList'[' + myValue +'].otherList[' + <c:out value='${valueBean}'/> + '].'someProp"

嘗試這個:

<input type="text" name="<%=curName%>[${valueBean}].otherList[${valueBean}].<%=curProp%>" value="<%=(String) currentItr.next()%>"/>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM