晚安。我不明白为什么jsf组件无法转换为html页面。我正在尝试创建将转换为html表的dataTable。JSF版本为-2.1.6-SNAPSHOT
└───WebContent
│ Main.jsp
│ Page 0.xhtml
│ Page1.xhtml
│
├───META-INF
│ MANIFEST.MF
│
├───resources
│ └───css
│ CSS.css
│
└───WEB-INF
│ faces-config.xml
│ web.xml
│
└───lib
javax.faces.jar
jstl-1.2.jar
我正在尝试使用http://localhost:8080/Practice/Page1.xhtml获取Page1 在xhtml之前:
<h:body>
<div class = "Task">
<h:dataTable value = "#{Countries.countries}" var = "country">
<h:column>
<f:facet name="header">Country</f:facet>
#{country.name}
//I have also tried outputText but the result is the same - empty
</h:column>
<h:column>
<f:facet name = "header">Capital</f:facet>
#{country.capital}
</h:column>
</h:dataTable>
</div>
这里将转换为HTML:
<div class="Task">
<h:dataTable value="[Lesson2.Country@4d1e67be, Lesson2.Country@81ce079, Lesson2.Country@7f6b1dc8, Lesson2.Country@395e8b9d]" var="country">
<h:column>
<f:facet name="header">Country</f:facet>
</h:column>
<h:column>
<f:facet name="header">Capital</f:facet>
</h:column>
</h:dataTable>
</div>
为什么没有转换jsf组件?
为什么在我试图显示国家/地区财产的地方没有空白? 在浏览器和Eclipse中都没有什么不对的地方。
这是我的完整.xhtml-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<h:head>
<title><ui:insert name="title">Default title</ui:insert></title>
</h:head>
<h:body>
<h:dataTable id = "Id" value = "#{Countries.countries}" var = "country">
<h:column>
<f:facet name="header">Country</f:facet>
<h:outputText value = "#{country.name}"/>
</h:column>
<h:column>
<f:facet name = "header">Capital</f:facet>
<h:outputText value = "#{country.capital}"/>
</h:column>
</h:dataTable>
这里匹配
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>