2017-10-04 125 views
1

我有一个jsf .xhtml文件。如果我使用文档类型JSF 2.2 <!doctype html>不工作

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

一切工作正常。但我想要一个HTML5网站。当我加入

<!doctype html> 

的doctype我收到此错误:

error on line 1 at column 2: StartTag: invalid element name 

请告诉我问题?

这里是我的web.xml:

<?xml version="1.0" encoding="UTF-8"?> 
<web-app version="3.0" 
    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_3_0.xsd"> 

    <display-name>ZaplianceLogAnalyser</display-name> 

    <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>*.html</url-pattern> 
    </servlet-mapping> 

    <context-param> 
     <description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description> 
     <param-name>javax.faces.STATE_SAVING_METHOD</param-name> 
     <param-value>client</param-value> 
    </context-param> 

    <context-param> 
     <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name> 
     <param-value>resources.application</param-value> 
    </context-param> 

    <listener> 
     <listener-class>com.sun.faces.config.ConfigureListener</listener-class> 
    </listener> 

    <context-param> 
     <param-name>javax.faces.DEFAULT_SUFFIX</param-name> 
     <param-value>.xhtml</param-value> 
    </context-param> 

</web-app> 
+2

尝试DOCTYPE –

+0

你已经解决问题了吗?如果是,请接受答案或发布解决方案以将问题标记为已关闭 – Al1

回答

0

你把

<web-app version="3.0" 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_3_0.xsd"> 

在web.xml文件?

+0

是的,这是我的Web.xml。好吧,它很长...我会paste.bin ist –

+0

在这里你去:https://pastebin.com/0Btah6gc –

+0

你有什么类型的编码这个文件(HTML)?您是否尝试以@mr mcwolf的形式使用大写的DOCTYPE? – soulcoder

0

您可以考虑以下变化:

  1. 使用<!DOCTYPE html>,而不是像<!doctype html>先生mcwolf建议
  2. 地图JSF页面来*.xhtml instead of *.html除非你有这样的选择已经一致的,但我看到,您将您的javax.faces.DEFAULT_SUFFIX设置为.xhtml,并且您正在使用.xhtml文件...更多reading about why .xhtml
  3. 我不是sur E对于web.xml中,但我现在已经习惯使用xmlns.jcp.org命名空间随处可见,而不是java.sun.com包括web.xml头:

    <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" 
    version="3.1" >