简体   繁体   English

JSF 2.2 <!doctype html> 不工作

[英]JSF 2.2 <!doctype html> not working

I have a jsf .xhtml file. 我有一个jsf .xhtml文件。 If I use the doctype 如果我使用文档类型

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

everything works fine. 一切正常。 But I'd like to have an HTML5-Site. 但是我想要一个HTML5-Site。 When I add the 当我添加

<!doctype html>

doctype I receive this error: doctype我收到此错误:

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

Whats the Problem? 有什么问题?

Here is my web.xml: 这是我的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>

Did you put 你放了吗

<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">

in your web.xml file? 在您的web.xml文件中?

You may consider the following changes: 您可以考虑以下更改:

  1. Use <!DOCTYPE html> instead of <!doctype html> like mr mcwolf suggested 使用<!DOCTYPE html>代替<!doctype html>mr mcwolf建议
  2. Map your JSF pages to *.xhtml instead of *.html unless you're already consistent with that choice but I see that you set your javax.faces.DEFAULT_SUFFIX to .xhtml and you are using .xhtml files... Further reading about why .xhtml 地图您的JSF页面*.xhtml而不是*.html ,除非你有这样的选择已经一致的,但我看到你设置你的javax.faces.DEFAULT_SUFFIX.xhtml和你正在使用.xhtml文件...更多阅读为什么.xhtml
  3. I'm not sure for web.xml but I now have the habit to use the xmlns.jcp.org namespace everywhere instead of java.sun.com including the web.xml header: 我不确定是否要使用web.xml,但是现在我习惯于在xmlns.jcp.org地方使用xmlns.jcp.org命名空间,而不是使用包括web.xml标头的java.sun.com

     <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" > 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM