servlet包的RequestDispatcher类没有FORWARD_REQUEST_URI字段 [英] RequestDispatcher class of the servlet package does not have FORWARD_REQUEST_URI field
问题描述
我正在尝试使用Maven构建Java EE应用程序。我的pom.xml中有以下内容:
I am trying to build a Java EE application using Maven. I have the following in my pom.xml:
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
根据 http://download.oracle.com/javaee/6/api/constant-values.html#javax.servlet.RequestDispatcher。 FORWARD_REQUEST_URI ,FORWARD_REQUEST_URI字段应该在那里,但事实并非如此。
According to http://download.oracle.com/javaee/6/api/constant-values.html#javax.servlet.RequestDispatcher.FORWARD_REQUEST_URI , the FORWARD_REQUEST_URI field should be there, however it isn't.
[ERROR] foo.java:[296,53] cannot find symbol
symbol : variable FORWARD_REQUEST_URI
location: interface javax.servlet.RequestDispatcher
项目目录中没有其他jar。我解压缩了〜/ .m2目录中的jar文件,它的文件可以追溯到5/10/2006。当我从pom.xml中删除依赖项时,它根本不编译。 (我安装了使用Netbeans EE的Glassfish服务器,所以我实际上可能会使用服务器的罐子吗?)
There are no other jars inside the project directory. I unzipped the jar file found in ~/.m2 directory, and it has files dating back to 5/10/2006. When I delete the dependency from the pom.xml, it doesn't compile at all. (I have Glassfish server installed with Netbeans EE, so I may actually use the server's jars I suppose?)
推荐答案
这个常数是在Servlet 3.0中引入。它在Servlet 2.5中不存在,另请参阅 RequestDispatcher
javadoc 。如果您使用的是Glassfish 3.x,它是一个Servlet 3.0容器,那么您应该能够将pom中的版本更新为 3.0
。然而,它应该是< scope>提供< / scope>
依赖。
This constant was introduced in Servlet 3.0. It's not present in Servlet 2.5, see also the Java EE 5 version of the RequestDispatcher
javadoc. If you're using Glassfish 3.x, which is a Servlet 3.0 container, then you should be able to update the version in pom to 3.0
. It's however supposed to be an <scope>provided</scope>
dependency.
这篇关于servlet包的RequestDispatcher类没有FORWARD_REQUEST_URI字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!