JSF myfacelet页面布局的问题
大家好,问一个关于使用myfacelet页面布局的问题。我按照大家的说法配置好了,也编写好了模板文件,但是在访问的时候,居然浏览器无法解析,即不是直接打开访问的页面,而是提示下载文件。很纳闷,不知大家是否有相同的经历。
web.xml文件如下:
<?xml version="1.0" encoding="UTF-8"?><web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.5" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <context-param> <param-name>javax.faces.DEFAULT_SUFFIX</param-name> <param-value>.xhtml</param-value> </context-param> <servlet> <servlet-name>Faces Servlet</servlet-name> <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> <load-on-startup>0</load-on-startup> </servlet> <servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>*.faces</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list></web-app>
<?xml version="1.0" encoding="UTF-8"?><!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://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"> <head> <title><ui:insert name="title">Facelets模板</ui:insert></title> </head> <body bgcolor="#ffffff" text="#000000" link="#023264" alink="#023264" vlink="#023264"> <table border="0" width="768px" align="center"> <tr> <td colspan="2"> <ui:insert name="header"> <ui:include src="header.xhtml" /> </ui:insert> </td> </tr> <tr> <td colspan="2"> <hr /> </td> </tr> <tr> <td width="140" valign="top"> <ui:insert name="menu"> <ui:include src="menu.xhtml" /> </ui:insert> </td> <td valign="middle" align="center"> <ui:insert name="body"> <ui:include src="body.xhtml" /> </ui:insert> </td> </tr> <tr> <td colspan="2"> <hr /> </td> </tr> <tr> <td colspan="2"> <ui:insert name="footer"> <ui:include src="footer.xhtml" /> </ui:insert> </td> </tr> </table> </body></html>
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><p>功能菜单<br/><br/>功能菜单<br/><br/>功能菜单<br/><br/>功能菜单<br/><br/>功能菜单<br/><br/></p>
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><p> <em><font size="6" color="gray"><strong>欢迎访问JSF页面布局方案</strong> </font> </em></p>
<?xml version="1.0" encoding="UTF-8"?><!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" xml:lang="en" lang="en" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"> <ui:composition template="layout.xhtml"> <ui:define name="title">主界面</ui:define> <ui:define name="body"> <div> <font size="6" color="gray"> <strong>欢迎访问Facelets页面布局方案</strong> </font> </div> </ui:define> </ui:composition></html>