Jsp ui:repeat不会为我呈现数据
Jsp ui:repeat不会为我呈现数据,jsp,jsf,jsf-1.2,Jsp,Jsf,Jsf 1.2,web.xml <!-- JavaServer Faces --> <context-param> <param-name>javax.faces.STATE_SAVING_METHOD</param-name> <param-value>server</param-value> </context-param> <context-param> <param-name&g
web.xml
<!-- JavaServer Faces -->
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
<context-param>
<param-name>javax.faces.CONFIG_FILES</param-name>
<param-value>/WEB-INF/faces-config.xml,/WEB-INF/faces-managed-beans.xml,/WEB-INF/faces-navigation.xml</param-value>
</context-param>
<context-param>
<param-name>org.richfaces.SKIN</param-name>
<param-value>blueSky</param-value>
</context-param>
<context-param>
<param-name>org.richfaces.CONTROL_SKINNING</param-name>
<param-value>enable</param-value>
</context-param>
<context-param>
<param-name>com.sun.faces.validateXml</param-name>
<param-value>true</param-value>
</context-param>
<filter>
<display-name>RichFaces Filter</display-name>
<filter-name>richfaces</filter-name>
<filter-class>org.ajax4jsf.Filter</filter-class>
</filter>
<filter-mapping>
<filter-name>richfaces</filter-name>
<servlet-name>Faces Servlet</servlet-name>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
</filter-mapping>
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
<!-- Faces Servlet -->
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>
org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
<!-- Faces Servlet Mapping -->
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<login-config>
<auth-method>BASIC</auth-method>
</login-config>
<?xml version="1.0" encoding="UTF-8"?>
<faces-config version="1.2" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd">
<validator>
<validator-id>com.test..view.validator.Regex</validator-id>
<validator-class>com.test..view.validator.regex.RegexValidator</validator-class>
</validator>
<application>
<locale-config>
<default-locale>en</default-locale>
</locale-config>
<message-bundle>com.test..view.resources.bundle.Messages</message-bundle>
</application>
</faces-config>
JSP文件
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<html>
<head>
</head>
<body onload="alert(\"test\")">
It works <hr/>
<f:view>
<h:form>
<ui:repeat value="${buildVehicleBean.buildVehicleBO.allVehicles}" var="var1">
<h:outputText value="#{var1.modelLineName}"/><br/>
</ui:repeat>
</h:form>
</f:view>
</body>
</html>
它可以工作
当我在浏览器中查看源代码时,我看到
...
<ui:repeat value="[com.test.model.bo.CarBO@3f9ba5,
com.test.model.bo.CarBO@38662,
com.test.model.bo.CarBO@16b9c59,
com.test.model.bo.CarBO@1e5bbb0,
com.test.model.bo.CarBO@1855620,
com.test.model.bo.CarBO@d984ff,
com.test.model.bo.CarBO@1dd4000,
com.test.model.bo.CarBO@100bb12,
com.test.model.bo.CarBO@f9d8ce]" var="var1">
<br/>
</ui:repeat>
...
。。。
...
正如您在ui中看到的,除了“br”标记外,没有其他内容:重复
这对我来说似乎很简单,显然我在某处遗漏了什么,很难找到它。如果我使用一些简单的东西,比如一个常量值,它就会工作
<h:outputText value="#{12345}"/><br/>
<h:outputText value="#{buildVehicleBean.testDouble}"/><br/>
如果在下一行中使用“#”而不是“$”,则会出现错误
<ui:repeat value="${buildVehicleBean.buildVehicleBO.allVehicles}" var="var1">
我是JSF新手,来自JSP和Struts背景。标签是视图技术的一部分。但您仍然在使用古老的JSP视图技术。它们不能一起使用。您不能在JSP中使用Facelets标记,也不能反过来使用。基本上,Facelets是JSP的继承者
您有两种选择:
- (在这种情况下,还可以升级到JSF2)
web.xml
,您似乎已经在使用RichFaces了。因此,只需在JSP顶部声明a4j
taglib,并使用
,如下所示:
...
谢谢你,巴卢斯克!我尝试过使用jstl forEach,但在forEach循环中,我无法使用h:outputText访问bean属性——这是不是我做错了什么,h:outputText是否也只适用于facelets?我试过了
效果很好!我很高兴能找到工作:)谢谢你的帮助。有一件事我想指出,在这个论坛上有很多答案是来自你的,太神奇了!不客气。只有在视图中预先引用了
{buildVehicleBean}
时,
才会起作用。${…}
语法即不会自动创建托管bean。再进一步看,既然你是新来的,请不要忘记在答案对解决问题有帮助(大部分)时标记为已接受。另见