JSF2如何在web.xml文件中指定多个自定义元素库 [英] JSF2 how to specify more than one custom element library in web.xml file

查看:113
本文介绍了JSF2如何在web.xml文件中指定多个自定义元素库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个自定义组件,我需要在同一个项目中同时使用它们. 我知道如何指定单个组件(教程: http ://myjavabuddy.blogspot.com/2013/04/writing-custom-components-for-jsf-20.html )(web.xml):

I have two custom components and I need to use them both on the same project. I know how to specify single component (tutorial: http://myjavabuddy.blogspot.com/2013/04/writing-custom-components-for-jsf-20.html) (web.xml):

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xmlns="http://java.sun.com/xml/ns/javaee"
  xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
  http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">

<context-param>
    <param-name>javax.faces.FACELETS_LIBRARIES</param-name>
    <param-value>/WEB-INF/marquee-taglib.xml</param-value>
</context-param>
</web-app>

一旦我添加了另一个组件(web.xml),第一个元素就会停止工作:

As soon as I add another component (web.xml) the first element stops working:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xmlns="http://java.sun.com/xml/ns/javaee"
  xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
  http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">

<context-param>
    <param-name>javax.faces.FACELETS_LIBRARIES</param-name>
    <param-value>/WEB-INF/marquee-taglib.xml</param-value>
</context-param>

<context-param>
    <param-name>javax.faces.FACELETS_LIBRARIES</param-name>
    <param-value>/WEB-INF/spinner-taglib.xml</param-value>
</context-param>
</web-app>

也不起作用:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xmlns="http://java.sun.com/xml/ns/javaee"
  xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
  http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">

<context-param>
    <param-name>javax.faces.FACELETS_LIBRARIES</param-name>
    <param-value>/WEB-INF/marquee-taglib.xml</param-value>
    <param-value>/WEB-INF/spinner-taglib.xml</param-value>
</context-param>
</web-app>

如何在同一个web.xml文件中指定两个自定义元素?

How can I specify two custom elements in the same web.xml file?

推荐答案

使用以下内容:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xmlns="http://java.sun.com/xml/ns/javaee"
  xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
  http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">

    <context-param>
        <param-name>javax.faces.FACELETS_LIBRARIES</param-name>
        <param-value>/WEB-INF/marquee-taglib.xml;/WEB-INF/spinner-taglib.xml</param-value>
    </context-param>
</web-app>

如果您使用myFaces,则可以在此处中查找配置参数期望的参数值

If you use myFaces you can look here for what param-values the configuration parameters expect.

这篇关于JSF2如何在web.xml文件中指定多个自定义元素库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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