如何不指定<;标题>;在我所有的JSF自定义组件上
继Oracle(和其他公司)之后,我的所有JSF组件如下所示:如何不指定<;标题>;在我所有的JSF自定义组件上,jsf,sonarqube,Jsf,Sonarqube,继Oracle(和其他公司)之后,我的所有JSF组件如下所示: <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:composite="http://xmlns.jcp.org/jsf/composite" > <composite:interface> ... </composite:interface> <composite:impleme
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:composite="http://xmlns.jcp.org/jsf/composite"
>
<composite:interface>
...
</composite:interface>
<composite:implementation>
...
</composite:implementation>
</html>
...
...
当然,它工作正常,但SonarCube不同意这一点(规则详细信息):
“标题”应出现在所有页面中
有两种解决方案:
- 要求声纳忽略这些问题
- 添加
和
标记
但是这些看起来像是解决办法,我想设置一个永久的解决方案。只有在可视化页面设计器中编写Facelets模板时,
DOCTYPE
和html
标记才是必需的。JavaEE教程的作者可能已经想到,这种开发人员将成为JSF用户的最大群体。然而,这毕竟是不真实的。事实上,这些可视化页面设计人员生成了糟糕的、非语义的源代码,其中充满了糟糕的HTML/CSS实践,之后必须进行清理
当您在纯文本编辑器中编写Facelets模板(当然带有语法高亮显示)时,在模板组合和合成中不一定需要这些DOCTYPE
和html
标记。
和
的根元素已经足够了
因此,在您的具体情况下,只需使用:
<ui:component
xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:cc="http://xmlns.jcp.org/jsf/composite"
>
<cc:interface>
...
</cc:interface>
<cc:implementation>
...
</cc:implementation>
</ui:component>
...
...
然后Sonar将不再错误地将其解释为“普通”HTML页面
另见: