我的问题如下。我们的项目最初是用JSF 1.2
编写的,文件扩展名为.jspx
。现在,当我从JSF 1.2迁移到JSF 2.1时,我遇到了在jspx
页面中使用JSF 2.0标签的问题。所以,web.xml
:
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.jspx</param-value>
</context-param>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
当我尝试使用时,我收到错误:
org.xml.sax.SAXException: PWC6143: No tag "head" defined in tag library associated with uri "http://java.sun.com/jsf/html"
at org.apache.jasper.compiler.JspDocumentParser.parseCustomAction(JspDocumentParser.java:1183)
at org.apache.jasper.compiler.JspDocumentParser.startElement(JspDocumentParser.java:429)
at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
at org.apache.jasper.compiler.JspDocumentParser.parse(JspDocumentParser.java:203)
at org.apache.jasper.compiler.ParserController.doParse(ParserController.java:208)
at org.apache.jasper.compiler.ParserController.parse(ParserController.java:124)
at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:184)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:409)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:592)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:344)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:470)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:364)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1221)
at ua.com.winforce.loto_partner.admin.filter.EncodingFilter.doFilter(EncodingFilter.java:14)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1212)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:399)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:766)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:450)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:928)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:549)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
但是,当我用.jspx
或任何其他扩展名替换javax.faces.DEFAULT_SUFFIX
文件扩展名和xhtml
param时,它可以正常工作。我也试着设置:
<context-param>
<param-name>DEFAULT_FACELETS_SUFFIX </param-name>
<param-value>.jspx</param-value>
</context-param>
<context-param>
<param-name>FACELETS_SUFFIX_PARAM_NAME</param-name>
<param-value>.jspx</param-value>
</context-param>
<context-param>
<param-name>DEFAULT_SUFFIX_PARAM_NAME</param-name>
<param-value>.jspx</param-value>
</context-param>
<context-param>
<param-name>FACELETS_VIEW_MAPPINGS_PARAM_NAME</param-name>
<param-value>.jspx</param-value>
</context-param>
问题 :我是否需要使用.jspx
或xhtml
或任何其他扩展来替换jsf
扩展名,以便使用所有JSF2
功能?