如何使用 JSF 2.0 和 EL 2.2 为 Tomcat 7 配置 Maven pom?
我想将 EL 2.2 用于 JSF 2 应用程序 tomcat 7 附带 EL 2.2 我对以下内容感到困惑:
1-我应该在我的 中提供 servlet-api、jsp-api 和 EL pom 文件(使用 maven)作为 提供 或根本不将它们包含在 pom 文件中,因为它们是由容器提供的,有什么区别?
<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?
3-web.xml 中是否需要任何其他配置,如本文所示:
http://code2inspire.wordpress.com/2010/11/05/how-to-enable-el-2-2-on-tomcat-6/
请告知。
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- 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- are they any required libraries to be added to pom file to be able to use EL 2.2 ?
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/
please advise.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不需要将其包含在 pom.xml 文件中,因为 tomcat 已包含该文件。但根据我的经验,当我尝试进行一些 servlet 编程时,需要在 pom 中包含 servlet-api 依赖项。就像你说的,定义提供的范围,因为它已经在 tomcat 中,并且你不希望在构建 war 时包含 pom 中的 servlet-api jar。我的 2 美分是只要依赖项正在运行就不要包含该依赖项,并在需要时包含它,然后在 pom.xml 中记录包含它的原因。
我认为您不需要声明任何其他依赖项,只要您的容器已经实现即可。我假设 tomcat 7 是这样,因为我也在使用它,并且我没有在 pom 依赖项中声明任何其他内容以便使用 EL 2.x
自从我使用 t7 以来从未尝试过它,但与核心 jsf 进行交叉检查第三版书,是的,那行得通
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.
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
Never tried it since im using t7, but crosschecking with the core jsf 3rd edition book, yeah, that'd work