Facelet标签库机制无法按预期工作 [英] Facelet Tag Library mechanism does not work as expected

查看:118
本文介绍了Facelet标签库机制无法按预期工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法将标签库打包到战争文件中.我将标签从项目移到当前项目所依赖的额外库中.我将taglibrary文件放入包含标签的jar的META-INF目录中(

I'm unable to pack taglibrary in a war file. I moved tags from project to extra library the current project is depending now. I put the taglibrary file into the META-INF directory of the jar containing tags (how is described here). But the page does not work:

Expression Error: Named Object: eu.barbucha.barbatag.simple.PropertyTag not found.

服务器能够找到标签库.否则,该页面将起作用,只会显示一个警告:

The server is able to find the taglibrary. Otherwise the page works, just one waring appears:

Warning: This page calls for XML namespace http://barbucha.eu/tags declared with prefix br but no taglibrary exists for that namespace.

因此,问题是:为什么服务器仅找到描述符,而不找到类?当我将类从WEB-INF/lib/barbatag.jar复制到WEB-INF/classes并在管理控制台中重新启动Webapp时,页面开始工作.服务器还仅在UI组件直接涉及应用程序的类而不是不包含在WEB-INF/lib目录中存储的jar中时,才找到UI组件.另一方面,服务器从罐子中加载taglib描述符.真令人困惑...关键类的声明:

Thus the question is: Why the server finds just the descriptor, but not the classes? When I copy classes from WEB-INF/lib/barbatag.jar into WEB-INF/classes and restart the webapp in administration console, the page gets working. The server also finds UI-components only if they are involved directly in classes of the applictation, but not in the jar stored in the WEB-INF/lib directory. On other hand the server loads taglib descriptor from the jar. It's really confusing... Declaration of the critical class:

package eu.barbucha.barbatag.simple;    

@FacesComponent("eu.barbucha.barbatag.simple.PropertyTag")
public class PropertyTag extends UIComponentBase { ... }

关键标签的定义:

<tag>
    <display-name>The component taking values from a property file</display-name>
    <tag-name>property</tag-name>
    <component>
        <component-type>eu.barbucha.barbatag.simple.PropertyTag</component-type>
    </component>
</tag>

一个重要的要点:我正在使用Spring MVC.

One potentionally important point: I'm using Spring MVC.

推荐答案

您需要在JAR中提供一个/META-INF/faces-config.xml文件,以使JSF扫描JAR文件中具有JSF特定注释的类,例如@FacesComponent.这样做是为了防止JSF不必要地在每个单独的JAR文件中扫描类(如果您有很多类,这可能会非常浪费时间和CPU).

You need to supply a /META-INF/faces-config.xml file in the JAR in order to get JSF to scan the JAR file for classes with JSF specific annotations like @FacesComponent. This is done so to prevent JSF from unnecessarily scanning every single JAR file for classes (which might be very time and CPU consuming if you have lot of them).

这篇关于Facelet标签库机制无法按预期工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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