简体   繁体   中英

cannot find symbol symbol: (maven and POM)

I finally fix nearly all that was wrong in my POM for maven compilation but there is still one wrong dependency (?) In my servlet class a have got 5 errors typeof

cannot find symbol
  symbol:   method getDispatcherType()
  location: variable request of type javax.servlet.http.HttpServletRequest
cannot find symbol
  symbol:   variable FORWARD
cannot find symbol
  symbol:   variable REQUEST

I have added in POM

<dependency>
            <groupId>javax.servlet.jsp.jstl</groupId>
            <artifactId>javax.servlet.jsp.jstl-api</artifactId>
            <version>1.2.1</version>
        </dependency>

and ( http://mvnrepository.com/artifact/javax.servlet.jsp.jstl/javax.servlet.jsp.jstl-api/1.2.1 )

<dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>javax.servlet.jsp-api</artifactId>
            <version>2.3.1</version>
        </dependency>

because getDispatcherType is from package javax.servlet; but it still couldn't find this methods, perhaps someone could tell me what is wrong in this POM description?

PS : org.glassfish.web:javax.servlet.jsp.jstl:1.2.1 is also present

You have the wrong dependency for jstl. You should be using:

<dependency>
  <groupId>javax.servlet</groupId>
  <artifactId>jstl</artifactId>
  <version>1.2</version>
</dependency>

Your jsp dependency is correct.

finally after a hours of screwing around that piece of code I have found what exactly caused such trouble - the dependency of tomcat-servlet-api MUST BE FIRST in section. I am using 7.0.50 version by the way.

<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.2</version>
</dependency>

update the version if you like to do so

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM