开发者

RequestDispatcher class of the servlet package does not have FORWARD_REQUEST_URI field

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>

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

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?)


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜