如何使用JSF 2.0和EL 2.2为Tomcat 7配置Maven pom? [英] How to configure Maven pom for Tomcat 7 with JSF 2.0 and EL 2.2?

查看:163
本文介绍了如何使用JSF 2.0和EL 2.2为Tomcat 7配置Maven pom?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将 EL 2.2 用于 JSF 2 应用程序
tomcat 7 提供EL 2.2
我对以下内容感到困惑:

i want to use EL 2.2 for JSF 2 application and tomcat 7 is provided with EL 2.2 and i am confused about the following:

1-我应该提供 servlet-api jsp-api 我的 pom 文件中的 EL (使用maven)作为提供,或者根本不在pom文件中包含它们,因为它们是由容器提供,有什么区别?

1- Should i provide the servlet-api, jsp-api and the EL in my pom file (using maven) as provided or don't include them at all in the pom file, since they are provided by container, what's the difference ?

<dependency>
          <groupId>javax.servlet</groupId>
          <artifactId>servlet-api</artifactId>
          <version>3.0</version>
          <scope>provided</scope>
         </dependency>


        <dependency>
          <groupId>javax.servlet.jsp</groupId>
          <artifactId>jsp-api</artifactId>
          <version>2.2</version>
          <scope>provided</scope>
        </dependency>

        <dependency>
         <groupId>javax.el</groupId>
         <artifactId>el-api</artifactId>
         <version>2.2</version>
         <scope>provided</scope>
       </dependency>

2-是否需要将任何库添加到pom文件才能使用EL 2.2?

2- are they any required libraries to be added to pom file to be able to use EL 2.2 ?

3- web.xml 中是否需要任何其他配置,如本文所述:

3- Is there's any additional configuration needed in web.xml as in this article:

http://code2inspire.wordpress.com/2010/11/05/how-to-enable-el-2-2-on-tomcat-6/

请告知。

推荐答案


  1. 一个不需要包含在pom中tomcat已经拥有.xml文件。但根据我的经验,当我尝试进行一些servlet编程时,需要在pom中包含servlet-api依赖。就像你说的那样,定义提供的范围,因为它已经在tomcat中了,你不希望在构建战争时包含来自pom的servlet-api jar。我的2美分不包括依赖项,只要它正在运行,并在需求出现时包含,然后在pom.xml中记录它包含的原因。

  1. One does not need to include in the pom.xml file as tomcat already has it. But in my experience, the needs arise to include the servlet-api dependency in the pom when i try to do some servlet programming. And like you said, define the scope as provided since it's already in the tomcat, and you dont want the servlet-api jar from pom to be included when building the war. My 2 cents is not to include the dependency as long as it's running, and include when the needs arise, and then document in the pom.xml the reason it's included.

我认为您不需要声明任何其他依赖项,只要您的容器已经实现了。我假设tomcat 7确实如此,因为我也使用它,并且我不会在pom依赖中声明任何其他内容以便使用EL 2.x

I dont think you need to declare any other dependencies, as long as your container has the implementation already. I assume tomcat 7 does, since i'm using it also, and i dont declare anything else in pom dependency in order to make use of EL 2.x

从来没有尝试过,因为即时通讯使用t7,但是使用核心jsf第3版书进行交叉检查,是的,那是有用的

Never tried it since im using t7, but crosschecking with the core jsf 3rd edition book, yeah, that'd work

这篇关于如何使用JSF 2.0和EL 2.2为Tomcat 7配置Maven pom?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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