我想要获得一个非常基本的JSF页面运行。使用Websphere 7.0作为服务器,所以我试图坚持使用JSF 1.2。浏览器不是呈现html,我的意思是它只是显示所有的html代码,包括文档类型等。
我的第一个猜测可能是它没有通过FacesServlet传递,但是当url-pattern没有通过时, t匹配它没有找到页面。 这是一个JSF版本问题?任何其他想法?谢谢大家JSF页面不呈现为HTML
我在我的lib文件夹中包含了jstl-api-1.2.jar和jstl-imp-1.2.jar。
我有以下的web.xml文件中建立:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<context-param>
<param-name>javax.faces.application.CONFIG_FILES</param-name>
<param-value>/WEB-INF/faces-config.xml</param-value>
</context-param>
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>
faces-config.xml中:
<?xml version="1.0"?>
<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
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"
version="1.2">
</faces-config>
的index.jsp:
<% response.sendRedirect("page-a.jsf"); %>
和所涉及的起动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:h="http://java.sun.com/jsf/html">
看起来你正在使用Facelets在你的项目中。如果是这种情况,那么后缀和模式有问题:Faces Servlet会处理每个_ *。jsf_页面,例如'http:// YourServerIP/YourProject/index.jsf',但默认后缀是* XHTML *。尝试将Faces Servlet模式更改为* .xhtml,并检查您是否正在访问像“http:// YourServerIP/YourProject/index.xhtml”这样的页面。 –