0
我不能得到h:command
發送param
給函數 的CAT1具有值AR數組,但我不能讓它發送param
在正確PARAM<c:forEach>和<h:commandLink>時無法發送PARAM起作用
JSP代碼
<c:forEach items="${categoryBean.getSubCategoryByID(0)}" var="cat" varStatus="stat">
<c:set var="cat1" scope="request" value="${cat}"/>
<li>
<c:out value="${cat1.id}" /> <c:out value="${cat1.name}" />
<h:commandLink id="goprime" action="#{categoryBean.gotoPrimecat}" value="#{cat1.name}">
<f:setPropertyActionListener target="#{categoryBean.CatID}" value="#{cat1.id}" />
</h:commandLink>
</li>
</c:forEach>
bean代碼
public String getCatID() {
return CatID;
}
public void setCatID(String CatID) throws SQLException, ClassNotFoundException {
logger.info("in setter: "+CatID);
this.CatID = CatID;
//products = product.searchProductsByCategory(null, null, CatID);
}
public void GotoPrimecat() throws IOException {
logger.info("in primercat , id: "+this.CatID);
ExternalContext context = FacesContext.getCurrentInstance().getExternalContext();
context.redirect("category.jsp");
return;
}
感謝您的答案,但仍然無法正常工作,f:setPropertyActionListener爲CatID設置空值 –
您的bean中的CatID屬性是否正確命名了getters和setters? – ewanc
下面的seeter和getter看起來似乎cat1並不是passet到JAVABEAN \t public String getCatID(){ return CatID; } \t public void setCatID(String CatID)throws SQLException,ClassNotFoundException {「in setter:」+ CatID); this.CatID = CatID; // products = product.searchProductsByCategory(null,null,CatID); } –