[英]using spring eval tag and call the java method in jsp without scriptlet
:-) :-)
I have a one question. 我有一个问题。 I want to checked status on my checkbox When myCode.id and checkedLists code value same. 我想在我的复选框上检查状态,当myCode.id和checkedLists代码值相同时。
<c:forEach var="myCode" items="${myCodeList }" varStatus="status">
<tr>
<th>
<input type="checkbox" id="myCode${status.index}" name="myCodes" />
</th>
<td>
<textarea id="myContent${status.index}" name="myContents"></textarea>
</td>
</th>
</tr>
</c:forEach>
I toss myCodeList and checkedList from my Controller. 我从我的控制器扔myCodeList和checkedList。 mycodeList is the list of the VO for some code list. mycodeList是某些代码列表的VO列表。 And checkedList is the list what I checked value from regist view. 而checkedList是我从注册器视图检查的值的列表。
<c:forEach var="myCode" items="${myCodeList }" varStatus="status">
<c:set var="myCodeFlag" value="false"
<tr>
<th>
<input type="checkbox" id="myCode${status.index}" name="myCodes"
<c:forEach var="checkedCode" items="${checkedList}">
<c:if test="${checkedCode.codId eq myCode.codId}">
checked="checked"
</c:if>
</c:forEach>
/>
</th>
<td>
<textarea id="myContent${status.index}" name="myContents"
<c:if test="${myCodeFlag eq flase}">disabeld="disabled"</c:if>>
<c:forEach var="checkedCode" items="${checkedList}">
<c:if test="${checkedCode.codId eq myCode.codId}">
${checkedCode.content}
</c:if>
</c:forEach>
</textarea>
</td>
</th>
</tr>
</c:forEach>
It works like what I want. 它像我想要的那样工作。
But my boss told me that change the code more simple. 但是我的老板告诉我,更改代码更加简单。 Use the spring eval tag and call the java method , It means using Java Lists method contain in JSP. 使用spring eval标记并调用java方法 ,这意味着使用JSP中包含的Java Lists方法。
So I tried like this in JSP page. 所以我在JSP页面中尝试了这种方法。 ${checkedList.contains('${myCode.codId }') }
But it doesn't work. 但这是行不通的。 What can I do to fix the problem? 我该如何解决该问题?
Thank for your help. 谢谢您帮忙。
Have a nice day :-) 祝你今天愉快 :-)
I change the way to solve it. 我改变解决方法。
In Controller, change the List of Object's to the Map of Objects. 在Controller中, 将“对象列表”更改为“对象映射”。
It means, I can write the code Like this. 这意味着,我可以像这样编写代码。
Before. 之前。
<c:forEach var="myCode" items="${myCodeList }" varStatus="status">
<c:set var="myCodeFlag" value="false"
<tr>
<th>
<input type="checkbox" id="myCode${status.index}" name="myCodes"
<c:forEach var="checkedCode" items="${checkedList}">
<c:if test="${checkedCode.codId eq myCode.codId}">
checked="checked"
</c:if>
</c:forEach>
/>
</th>
<td>
<textarea id="myContent${status.index}" name="myContents"
<c:if test="${myCodeFlag eq flase}">disabeld="disabled"</c:if>>
<c:forEach var="checkedCode" items="${checkedList}">
<c:if test="${checkedCode.codId eq myCode.codId}">
${checkedCode.content}
</c:if>
</c:forEach>
</textarea>
</td>
</th>
</tr>
</c:forEach>
After. 后。
<textarea id="myContent${status.index}" name="myContents"
<c:if test="${checkedCodeMap[checkCode.codValue].category.codId ne myCode.codId}">disabeld="disabled"</c:if>>
<c:if test="${checkedCodeMap[checkCode.codValue].category.codId ne myCode.codId}">
${checkedCodeMap[checkCode.codValue].content}
</c:if>
</textarea>
It's better to read than before. 比以前阅读更好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.