【发布时间】:2011-02-27 21:38:15
【问题描述】:
我的 JSP 中有以下代码。我正在使用一个 Struts 表单,我在其中传递了一个正在迭代的 List,并且 List 中的每个项目都有自己单独的表单。列表中的所有字段都是字符串,除了 id,它是一个 int。我试图在 s:hidden 标记中呈现 int,但 Eclipse 告诉我“无效的属性(值)”。 Struts 文档说该值需要一个字符串,但我将 bulletins.id 包装在 ${...} 中,这应该将其转换为字符串。我已经进行了多次 Google 搜索以尝试解决此问题,但我一无所获。有人见过这个吗?
<%@ page import="java.io.*"%>
<%@ page import="java.util.List"%>
<%@ page language="java" import="model.Bulletin"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!-- Some more code here that's not relevant to this problem -->
<c:forEach var="bulletins" items="${bulletins}">
<c:if test="${bulletins.approved == false}">
<s:form action="ApproveBulletin" method="post">
<table>
<tr>
<td colspan="2"><b>From:</b> <c:out value="${bulletins.name}" /></td>
</tr>
<tr>
<td colspan="2"><b>Subject:</b> <c:out value="${bulletins.subject}" /></td>
</tr>
<tr>
<td colspan="2"><b>Date:</b> <c:out value="${bulletins.date}" /> <br>
</td>
</tr>
<tr>
<td colspan="2"><c:out value="${bulletins.note}" />
<!-- Error here --> <s:hidden name="id" value="${bulletins.id}" /></td>
</tr>
<tr>
<td><s:submit type="button" value="approve" label="Approve"
action="ApproveBuletin" /></td>
<td><s:submit type="button" value="deny" label="Deny"
action="DenyBulletin" /></td>
</tr>
</table>
<br />
</s:form>
</c:if>
</c:forEach>
<!-- Some more code here that's not relevant to this problem -->
【问题讨论】: