[英]<c:forEach> and <h:commandLink> not able to work together?
Hi I have a jsp page like this 嗨,我有一个像这样的jsp页面
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Compact Output</title>
</head>
<body>
<f:view>
<h:form>
<c:forEach items="${bean.itemlist}" var="item">
<h:panelGrid columns="1" id="panel1">
<h2><c:out value="${item.displayName}" /></h2>
<img src="<c:out value="${item.thumbnailURI}"/>" height="600" width="800" />
<h:commandLink action="#{bean.action1}" value="Details">
<f:param name="selecteddisplayName" value="#{item.displayName}" />
</h:commandLink>
</h:panelGrid>
</c:forEach>
</h:form>
</f:view>
</body>
</html>
I put 我放
<h:commandLink action="#{bean.action1}" value="Details">
<f:param name="selecteddisplayName" value="#{item.displayName}" />
</h:commandLink>
inside the tag, but when click the link, the #{bean.action1} got called, but the parameter item.displayName is not passed to the controller. 标记中,但是单击链接时,调用了{{bean.action1},但未将参数item.displayName传递给控制器。 I tried to change it to ${item.displayName} then I got compile error "value" does not support runtime expressions.
我试图将其更改为$ {item.displayName},然后出现编译错误“值”不支持运行时表达式。
What is wrong with my jsp page? 我的jsp页面出了什么问题?
In my controller I have defined private String selecteddisplayName and getter/setters. 在我的控制器中,我定义了私有字符串selecteddisplayName和getter / setters。
Maybe can not work together with ? 也许不能一起工作?
if u want to set values in property than 如果您想在属性中设置值
try <f:setPropertyActionListener value="" target=""/>
instead of <f:param name="selecteddisplayName" value="#{item.displayName}" />
尝试
<f:setPropertyActionListener value="" target=""/>
而不是<f:param name="selecteddisplayName" value="#{item.displayName}" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.