JSF2 /......registerHostUser.xhtml @ 9,9< h:head>标记库支持名称空间:http://java.sun.com/jsf/html,但没有为名称:head定义标记 [英] JSF2 /......registerHostUser.xhtml @9,9 <h:head> Tag Library supports namespace: http://java.sun.com/jsf/html, but no tag was defined for name: head
问题描述
我是JSF 2的新手,因为我正在尝试做一个hello世界的例子来亲身体验我,我遇到了这个错误,我一直在尝试一段时间。
StackTrace
om.sun.facelets.tag.TagException:/ facelets / register / host / registerHostUser.xhtml @ 9,9< h:head>标签库支持名称空间:http://java.sun.com/jsf/html,但没有标签被定义为名称:头
在com.sun.facelets.compiler.CompilationManager.pushTag(CompilationManager.java:193 )
at com.sun.facelets.compiler.SAXCompiler $ CompilationHandler.startElement(SAXCompiler.java:194)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser .java:501)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.startElement(XMLDTDValidator.java:767)
at com.sun.org.apache.xerces .internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:400)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl $ FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2755)
在com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)
位于com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl。 java的:140 )
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration .parse(XML11Configuration.java:808)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
at com.sun.org.apache .xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl $ JAXPSAXParser.parse(SAXParserImpl.java:522)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:395)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:198)
at com.sun.facelets.compiler.SAXCompiler.doCompile(SAXCompiler.java:232)
at com.sun .facelets.compiler.Compiler.compile(Compiler.java:105)
at com.sun.facelets.impl.DefaultFaceletFactory.createFacelet(DefaultFaceletFactor y.java:218)
at com.sun.facelets.impl.DefaultFaceletFactory.getFacelet(DefaultFaceletFactory.java:149)
at com.sun.facelets.impl.DefaultFaceletFactory.getFacelet(DefaultFaceletFactory.java: 100)
at com.sun.facelets.FaceletViewHandler.buildView(FaceletViewHandler.java:517)
at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:567)
at com .sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces .lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
位于javax.faces.webapp.FacesServlet.service(FacesServlet.java:410)
位于org.apache.catalina.core.StandardWrapper.service (StandardWrapper.java:1534)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java :175)
在org.apache.catalina.core.StandardPipeline.doInvoke(Stan dardPipeline.java:655)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java: 98)
at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:326)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:227)
at com .sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:170)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:822)
at com .sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:719)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1013)
at com.sun.grizzly .http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
at com.sun.grizzly.DefaultPro tocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java: 90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
在com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
在com.sun.grizzly.ContextTask.run(ContextTask.java:71)
在com.sun.grizzly.util .AbstractThreadPool $ Worker.doWork(AbstractThreadPool.java:532)
at com.sun.grizzly.util.AbstractThreadPool $ Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run (Thread.java:662)
pom.xml
< project xmlns =http://maven.apache.org/POM/4.0.0xmlns:xsi =http:/ /www.w3.org/2001/XMLSchema-instance
xsi:schemaLocation =http:/ /maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd\">
< modelVersion> 4.0.0< / modelVersion>
< groupId> sg.java< / groupId>
< artifactId> web.vms< / artifactId>
<包装>战争< / packaging>
< version> 0.0.1-SNAPSHOT< / version>
<依赖关系>
< dependency>
< groupId> junit< / groupId>
< artifactId> junit< / artifactId>
< version> $ {junit.version}< / version>
< scope> test< / scope>
< /依赖关系>
< dependency>
< groupId> com.sun.faces< / groupId>
< artifactId> jsf-api< / artifactId>
< version> $ {faces.version}< / version>
< scope>提供< / scope>
< /依赖关系>
< dependency>
< groupId> com.sun.faces< / groupId>
< artifactId> jsf-impl< / artifactId>
< version> $ {faces.version}< / version>
< scope>提供< / scope>
< /依赖关系>
< dependency>
< groupId> com.sun.facelets< / groupId>
< artifactId> jsf-facelets< / artifactId>
<版本> $ {facelets.version}< / version>
< scope>编译< / scope>
< /依赖关系>
< dependency>
< groupId> javax.el< / groupId>
< artifactId> el-api< / artifactId>
< version> 2.2< / version>
< /依赖关系>
< dependency>
< groupId> org.glassfish.web< / groupId>
< artifactId> el-impl< / artifactId>
< version> 2.2< / version>
< /依赖关系>
< dependency>
< groupId> org.primefaces< / groupId>
< artifactId> primefaces< / artifactId>
< version> $ {primeFaces.version}< / version>
< /依赖关系>
< /依赖关系>
< build>
< finalName> vms< / finalName>
< plugins>
< plugin>
< groupId> org.apache.maven.plugins< / groupId>
< artifactId> maven-compiler-plugin< / artifactId>
< version> 2.0.2< / version>
<配置>
< source> 1.6< / source>
< target> 1.6< / target>
< / configuration>
< / plugin>
< plugin>
< groupId> org.apache.maven.plugins< / groupId>
< artifactId> maven-war-plugin< / artifactId>
< version> 2.1.1< / version>
<配置>
< failOnMissingWebXml> false< / failOnMissingWebXml>
< webXml> src / main / webapp / WEB-INF / web.xml< / webXml>
< / configuration>
< / plugin>
< / plugins>
< / build>
< repositories>
< repository>
< id> java.net< / id>
< name> java.net< / name>
< url> http://download.java.net/maven/2< / url>
< / repository>
< repository>
< id> prime-repo< / id>
< name> Prime Technology Maven仓库< /名称>
< url> http://repository.prime.com.tr< / url>
< layout>预设< / layout>
< / repository>
<! - - http://community.jboss.org/wiki/MavenGettingStarted-Developers - >
< repository>
< id> jboss-public-repository-group< / id>
< name> JBoss公共存储库组< /名称>
< url> http://repository.jboss.org/nexus/content/groups/public/< / url>
< layout>预设< / layout>
<发布>
< enabled> true< / enabled>
< updatePolicy>永不< / updatePolicy>
< / releases>
<快照>
< enabled> true< / enabled>
< updatePolicy>永不< / updatePolicy>
< / snapshots>
< / repository>
< / repositories>
<属性>
< junit.version> 4.8.2< /junit.version>
< primeFaces.version> 2.2< /primeFaces.version>
< faces.version> 2.0.3< /faces.version>
< javaee.version> 1.0.0.Final< /javaee.version>
< facelets.version> 1.1.15.B1< /facelets.version>
< / properties>
registerHostUser.xhtml
<?xml version =1.0encoding =UTF-8?>
<!DOCTYPE html PUBLIC - // W3C // DTD XHTML 1.0 Transitional // EN
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional。 DTD>
xmlns:h =http://java.sun.com/jsf/html
xmlns:f =http://java.sun.com/jsf/core
xmlns:ui =http://java.sun.com/jsf/facelets>
< h:head>
< title>注册主机用户< / title>
< / h:头>
< h:body>
< h:form>
注册主机用户< br />
电子邮件:< h:inputText label =Emailid =email
value =#{hostUserRegistrationBackingBean.email}required =true/>
< h:message for =email/>
< p>< / p>
< h:commandButton value =Registeraction =confirm/>
< / h:表格>
< / h:body>
< / html>
faces-config.xml
<?xml version =1.0encoding =UTF-8?>
< faces-config version =2.0xmlns =http://java.sun.com/xml/ns/javaeexmlns:xi =http://www.w3.org/2001/ XIncludexmlns: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_2_0.xsd\">
< application>
< view-handler> com.sun.facelets.FaceletViewHandler< / view-handler>
< locale-config>
< default-locale> en< / default-locale>
< / locale-config>
< resource-bundle>
< base-name> sg.java.web.vms.messages< / base-name>
< var> msg< / var>
< / resource-bundle>
< / application>
< / faces-config>
web.xml
< web-app version =2.5xmlns =http://java.sun.com/xml/ns/javaeexmlns: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-app_2_5.xsd\">
< context-param>
< param-name> javax.faces.PROJECT_STAGE< / param-name>
<参数值>开发< /参数值>
< / context-param>
< context-param>
< param-name> com.sun.faces.expressionFactory< / param-name>
< param-value> com.sun.el.ExpressionFactoryImpl< / param-value>
< / context-param>
< servlet>
< servlet-name> Faces Servlet< / servlet-name>
< servlet-class> javax.faces.webapp.FacesServlet< / servlet-class>
1< / load-on-startup>
< / servlet>
< servlet-mapping>
< servlet-name> Faces Servlet< / servlet-name>
< url-pattern> / faces / *< / url-pattern>
< / servlet-mapping>
< servlet-mapping>
< servlet-name> Faces Servlet< / servlet-name>
< url-pattern> *。jsf< / url-pattern>
< / servlet-mapping>
< servlet-mapping>
< servlet-name> Faces Servlet< / servlet-name>
< url-pattern> *。xhtml< / url-pattern>
< / servlet-mapping>
< welcome-file-list>
< welcome-file> faces / facelets / register / host / registerHostUser.xhtml< / welcome-file>
< / welcome-file-list>
不确定这是什么原因造成的,以及Maven如何扮演角色,因为我没有使用它,但我发现至少有三个潜在原因:
-
您的
/ WEB-INF / lib
或classpath中的其他位置都有JSF 1.x库。删除它(或指示Maven不要包含它们)。 Glassfish 3已经包含内置的JSF 2.x库。< h:head>
在JSF 2.0中引入,因此在JSF 1.x中不存在。 -
FaceletViewHandler
声明在faces-config.xml
中是完全多余的。去掉它。这只在您使用JSF 1.x时才是必需的。 JSF 2.x默认使用Facelets。如果你添加它,因为你无法运行Facelets,那么整个问题肯定是由原因#1引起的(然后删除任何Facelets 1.x库)。 $ b -
web.xml
未被声明为Servlet 3.0。我不确定Glassfish如何在提供的JSF实现方面采取行动,但是只要容器支持它,就应该声明Servlet 3.0。<?xml version =1.0encoding =UTF-8?>
< web-app
xmlns =http://java.sun.com/xml/ns/javaee
xmlns:web =http://java.sun.com /xml/ns/javaee/web-app_3_0.xsd
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-app_3_0.xsd
id =Your_Webapp_IDversion =3.0>
<! - 此处配置 - >
< / web-app>
另外
com.sun.faces.expressionFactory
param对于Servlet 3.0来说是完全多余的,因为它已经是Glassfish默认的一个。
与具体问题无关,我建议将 FacesServlet
映射降到最低。坚持 *。xhtml
一个并摆脱其他人。
i am new to JSF 2 as i am trying to do a hello world example to familarise myself, i hit this error which i have been trying out for quite some days.
StackTrace
om.sun.facelets.tag.TagException: /facelets/register/host/registerHostUser.xhtml @9,9 <h:head> Tag Library supports namespace: http://java.sun.com/jsf/html, but no tag was defined for name: head
at com.sun.facelets.compiler.CompilationManager.pushTag(CompilationManager.java:193)
at com.sun.facelets.compiler.SAXCompiler$CompilationHandler.startElement(SAXCompiler.java:194)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:501)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.startElement(XMLDTDValidator.java:767)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:400)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2755)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:395)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:198)
at com.sun.facelets.compiler.SAXCompiler.doCompile(SAXCompiler.java:232)
at com.sun.facelets.compiler.Compiler.compile(Compiler.java:105)
at com.sun.facelets.impl.DefaultFaceletFactory.createFacelet(DefaultFaceletFactory.java:218)
at com.sun.facelets.impl.DefaultFaceletFactory.getFacelet(DefaultFaceletFactory.java:149)
at com.sun.facelets.impl.DefaultFaceletFactory.getFacelet(DefaultFaceletFactory.java:100)
at com.sun.facelets.FaceletViewHandler.buildView(FaceletViewHandler.java:517)
at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:567)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:410)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1534)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:326)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:227)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:170)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:822)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:719)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1013)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:662)
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>sg.java</groupId>
<artifactId>web.vms</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>${faces.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>${faces.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sun.facelets</groupId>
<artifactId>jsf-facelets</artifactId>
<version>${facelets.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>javax.el</groupId>
<artifactId>el-api</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>el-impl</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>${primeFaces.version}</version>
</dependency>
</dependencies>
<build>
<finalName>vms</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<webXml>src/main/webapp/WEB-INF/web.xml</webXml>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>java.net</id>
<name>java.net</name>
<url>http://download.java.net/maven/2</url>
</repository>
<repository>
<id>prime-repo</id>
<name>Prime Technology Maven Repository</name>
<url>http://repository.prime.com.tr</url>
<layout>default</layout>
</repository>
<!-- http://community.jboss.org/wiki/MavenGettingStarted-Developers -->
<repository>
<id>jboss-public-repository-group</id>
<name>JBoss Public Repository Group</name>
<url>http://repository.jboss.org/nexus/content/groups/public/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
</repository>
</repositories>
<properties>
<junit.version>4.8.2</junit.version>
<primeFaces.version>2.2</primeFaces.version>
<faces.version>2.0.3</faces.version>
<javaee.version>1.0.0.Final</javaee.version>
<facelets.version>1.1.15.B1</facelets.version>
</properties>
registerHostUser.xhtml
<?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:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
<title>Register Host User</title>
</h:head>
<h:body>
<h:form>
Register Host User<br />
Email: <h:inputText label="Email" id="email"
value="#{hostUserRegistrationBackingBean.email}" required="true" />
<h:message for="email" />
<p></p>
<h:commandButton value="Register" action="confirm" />
</h:form>
</h:body>
</html>
faces-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<faces-config version="2.0" 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_2_0.xsd">
<application>
<view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
<locale-config>
<default-locale>en</default-locale>
</locale-config>
<resource-bundle>
<base-name>sg.java.web.vms.messages</base-name>
<var>msg</var>
</resource-bundle>
</application>
</faces-config>
web.xml
<web-app version="2.5" 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-app_2_5.xsd">
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<context-param>
<param-name>com.sun.faces.expressionFactory</param-name>
<param-value>com.sun.el.ExpressionFactoryImpl</param-value>
</context-param>
<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>/faces/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>faces/facelets/register/host/registerHostUser.xhtml</welcome-file>
</welcome-file-list>
Not sure how exactly this is caused and how exactly Maven plays a role since I don't use it, but I see at least three potential causes:
You have JSF 1.x libraries in your
/WEB-INF/lib
or elsewhere in classpath. Remove it (or instruct Maven to not include them). Glassfish 3 already ships with builtin JSF 2.x libraries. The<h:head>
was namely introduced in JSF 2.0 and is thus absent in JSF 1.x.The
FaceletViewHandler
declaration infaces-config.xml
is entirely superfluous. Remove it. This is only mandatory when you're using JSF 1.x. JSF 2.x uses by default Facelets. If you did add it because you couldn't get Facelets to run, then the whole problem is definitely caused by cause #1 (and then remove any Facelets 1.x libraries as well).The
web.xml
is not been declared as Servlet 3.0. I'm not sure how Glassfish acts on this with regard to the provided JSF implementation, but you should be declaring Servlet 3.0 whenever the container supports it.<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" 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-app_3_0.xsd" id="Your_Webapp_ID" version="3.0"> <!-- Config here --> </web-app>
Also the
com.sun.faces.expressionFactory
param is entirely superfluous with Servlet 3.0 since it is already the Glassfish-default one.
Unrelated to the concrete problem, I recommend to bring the FacesServlet
mappings to a minimum. Stick to the *.xhtml
one and get rid of the others.
这篇关于JSF2 /......registerHostUser.xhtml @ 9,9< h:head>标记库支持名称空间:http://java.sun.com/jsf/html,但没有为名称:head定义标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!