我想根据foreach
内的值显示启用或禁用的按钮。它应该检查值是否为" true" - 一个字符串并显示一个看起来已启用的按钮(html按钮)。如果它是假的,它应该看起来是禁用的。
<table border ="1">
<tr class ="tableheading">
<td>UniqueId</td><td>ClientId</td><td>Request Date and Time</td><td>Connection Status</td></tr>
<c:forEach items="${list}" var="item">
<tr class ="rowstyle">
<td class ="rowstyle">${item.getUniqueId()}</td>
<td >${item.getClientId()}</td>
<td >${item.getRequestDateTime()}</td>
<c:choose>
<c:when test = "${item.getConnectionStatus == true}">
<td ><a href="screenviewer.html?clientID=${item.getClientId()}"><button style = "width:60px">${item.getConnectionStatus()}
</c:when>
<c:otherwise>
<td ><a href="screenviewer.html?clientID=${item.getClientId()}"><button disabled style = "width:60px">${item.getConnectionStatus()}
</c:otherwise>
</c:choose>-->
</button></a></td>
</tr>
</c:forEach>
</table>
如果<td>
为真,则应显示带getConnectionStatus
的按钮。
例外:
org.apache.jasper.JasperException: An exception occurred processing JSP page /DisplayClientLoginDetails.jsp at line 44
第44行:
44:<c:when test = "${item.getConnectionStatus == true}">
Bean类:
public class ClientLoginBean {
private String UniqueId,ClientId,RequestDateTime,connectionStatus;
public String getUniqueId() {
return UniqueId;
}
public void setUniqueId(String UniqueId) {
this.UniqueId = UniqueId;
}
public String getClientId() {
return ClientId;
}
public void setClientId(String ClientId) {
this.ClientId = ClientId;
}
public String getRequestDateTime() {
return RequestDateTime;
}
public void setRequestDateTime(String RequestDateTime) {
this.RequestDateTime = RequestDateTime;
}
public String getConnectionStatus() {
return connectionStatus;
}
public void setConnectionStatus(String ConnectionStatus) {
this.connectionStatus = ConnectionStatus;
}
}
答案 0 :(得分:0)
如果没有完整的例外,很难确定,我的猜测是你的测试语句test = "${item.getConnectionStatus == true}"
中的getter。以下是一些Oracle文档的小片段,
如果value-a是JavaBeans对象,则将value-b强制转换为String。如果value-b是value-a的可读属性,则返回get调用的结果。如果get方法抛出异常,则返回错误。
您是否尝试通过EL的隐式getter方法访问项目的connectionStatus(删除 get 并将属性值更改为小写)?
<c:when test="${item.connectionStatus == true}">