放置<角色>在Facelets组成中的消息显示消息“此处不允许属性角色". [英] Putting <a role> in Facelets composition shows message "Attribute role is not allowed here"

查看:117
本文介绍了放置<角色>在Facelets组成中的消息显示消息“此处不允许属性角色".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚尝试使用引导程序设置我的jsf项目.一切正常,除了添加包含"role"属性的引导程序模板时.我收到一条消息,提示此处不允许使用角色角色

I just tried to setup my jsf project with bootstrap. Everything works fine except that when I added a bootstrap template that includes the "role" attribute. I get a message that says Attribute role is not allowed here

我对设计不满意,我将更多的精力放在后端上,所以我真的需要使用引导程序.

I'm not good with design and I'm focusing more with the backend so I really need to use bootstrap.

<?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://xmlns.jcp.org/jsf/html"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:f="http://xmlns.jcp.org/jsf/core">
<ui:composition>
    <div class="row">
        <div class="col-sm-6 col-md-4">
            <div class="thumbnail">
                <img src="..." alt="..."/>
                <div class="caption">
                    <h3>Thumbnail label</h3>
                    <p>...</p>
                    <p><a href="#" class="btn btn-primary" role="button">Button</a> <a href="#" class="btn btn-default" role="button">Button</a></p>
                </div>
            </div>
        </div>
    </div>
</ui:composition>
</html>

我无法弄清楚为什么所有其他标签和属性都被识别后,它不会读取该属性.

I can't figure out why it won't read that attribute when all other tags and attributes are recognized.

任何可能的解决方案?

Any possible solution?

谢谢.

推荐答案

您的文档类型错误. role属性是HTML5(ARIA)的一部分,而不是XHTML 1.0.

Your doctype is wrong. The role attribute is part of HTML5 (ARIA), not XHTML 1.0.

相应地修复文档类型.

<!DOCTYPE html>

您的编辑器(IDE)仅基于doctype验证文档.这不是JSF也不是Bootstrap的特定问题.这与基本HTML有关.

Your editor (IDE) is just validating the document based on doctype. This is not a JSF nor Bootstrap specific problem. This is related to basic HTML.

顺便说一句,在Facelets合成中,您实际上实际上严格不需要XML序言或doctype.无论如何,这些都将被Facelets忽略.以下内容应能很好地发挥作用:

By the way, in Facelets compositions you actually don't strictly need a XML prolog nor doctype. Those will be ignored by Facelets anyway. Below should work as good in its entirety:

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
>
    <!-- Content here -->
</ui:composition>

另请参见:

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆