[英]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: 您可以考虑以下更改:
<!DOCTYPE html>
instead of <!doctype html>
like mr mcwolf suggested <!DOCTYPE html>
代替<!doctype html>
如mr mcwolf建议 *.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
*.xhtml
而不是*.html
,除非你有这样的选择已经一致的,但我看到你设置你的javax.faces.DEFAULT_SUFFIX
到.xhtml
和你正在使用.xhtml
文件...更多阅读为什么.xhtml
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.