简体   繁体   English

Jsf 2.0自定义标签

[英]Jsf 2.0 Custom Tag

I get the following error on every page of my project when I am removing the MyFaces-2.0 entry from web.xml. 当我从web.xml中删除MyFaces-2.0条目时,我在项目的每个页面上都出现以下错误。 My project is created using JSF 2.0. 我的项目是使用JSF 2.0创建的。

Error : 错误

One or more resources have the target of 'head', but no 'head' component has been defined within the view. 一个或多个资源的目标是“head”,但视图中没有定义“head”组件。

web.xml : web.xml

<context-param>
    <param-name>org.jboss.jbossfaces.JSF_CONFIG_NAME</param-name>
    <param-value>MyFaces-2.0</param-value>
</context-param>

After removing that entry my custom tag runs. 删除该条目后,我的自定义标记会运行。 If I put this in web.xml again, then the compiler doesn't go to the component class. 如果我再次将它放在web.xml中,那么编译器不会转到组件类。

As the message you got says, you have no head component in your view (on your Facelet). 正如您所说的消息所示,您的视图中没有头部组件(在您的Facelet上)。 Such a component is needed for other components that eg want to inject scripts and css resources into the head. 对于例如想要将脚本和css资源注入头部的其他组件,需要这样的组件。

The remedy is to simply add this component on your Facelet, eg: 解决方法是简单地在Facelet上添加此组件,例如:

<!DOCTYPE html>
<html lang="en"
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"  
>
    <!-- The head component that was missing -->
    <h:head/>

    <h:body>
        <!-- Other components here -->
    </h:body>
</html>

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

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