我正在尝试在Glassfish 3.1.2服务器上使用HTML5 doctype和jsf 2.1和Facelets .
我见过很多地方我们可以用html5 doctype替换xhtml doctype
<!DOCTYPE html>
并在-tag中保留xhtml的xml . 在一些论坛上,他们说就是这样 . 但事实并非如此,至少Firefox不同意,因为它将页面呈现为“HTML propritary”而不是HTML5 .
似乎没有教程考虑html页面文件扩展名?这是浏览器关心的东西吗?我试图将此从* .xhtml更改为* .html,从-tag中删除xhtml命名空间,并在web.xml中更改
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
至
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.html</param-value>
</context-param>
并为html添加了servlet映射 . 这根本不起作用 .
好吧,然后我将所有内容恢复为默认值(xhtml / facelets),仅替换doctype-tag并删除引用xhtml的xmlns(来自所有文件/模板) . 现在我得到了许多警告,如下:
Warning: This page calls for XML namespace declared with prefix li but no taglibrary exists for that namespace.
Warning: This page calls for XML namespace declared with prefix li but no taglibrary exists for that namespace.
Warning: This page calls for XML namespace declared with prefix li but no taglibrary exists for that namespace.
Warning: This page calls for XML namespace declared with prefix body but no taglibrary exists for that namespace.
Warning: This page calls for XML namespace declared with prefix ul but no taglibrary exists for that namespace.
Warning: This page calls for XML namespace declared with prefix form but no taglibrary exists for that namespace.
Warning: This page calls for XML namespace declared with prefix a but no taglibrary exists for that namespace.
Warning: This page calls for XML namespace declared with prefix a but no taglibrary exists for that namespace.
Warning: This page calls for XML namespace declared with prefix a but no taglibrary exists for that namespace.
Warning: This page calls for XML namespace declared with prefix a but no taglibrary exists for that namespace.
好吧,这看起来并不乐观 . 在web.xml中,我将项目阶段从开发改为 生产环境 .
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Production</param-value>
</context-param>
警告消失了,w3c的验证器说这是有效的html5 .
有人有更好的解决方案吗? jsf / facelets是否要求文件具有扩展名xhtml?
2 回答
就我而言,添加命名空间不是一个好的解决方案:
以上肯定会使Facelets解析器满意,但命名空间会被写入生成的HTML中,而W3C Validator无法将其正确检测为HTML5 .
不使用命名空间工作和验证很好,但当然上面提到了我的.xhtml文件中使用的每个普通HTML标记的警告 .
为了摆脱这些警告,我不得不创建一个自定义
FacesContext
:工厂:
faces-config.xml
:这似乎有效 .
您需要将定义HTML元素的XML命名空间声明为全局XML命名空间 .
那是,