Mysterious Eclipse JSP Validation Errors

前端 未结 16 1943
你的背包
你的背包 2021-01-30 08:50

Eclipse (Helios) occasionally marks valid looking JSP content as having errors. It seems like it often breaks when I use the tag. For example, in a JSP with just th

相关标签:
16条回答
  • 2021-01-30 09:02

    For Tomcat 7.0.x you need the following in your pom

    <properties>
        <org.apache.tomcat.version>7.0.28</org.apache.tomcat.version>
    </properties>
    
    <dependencies>
        <dependency>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>tomcat-jsp-api</artifactId>
            <version>${org.apache.tomcat.version}</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
    
    0 讨论(0)
  • 2021-01-30 09:05

    Solution for eclipse dependencies which should not be deployed is adding UserLibrary container, and include it in dependent projects.

    1. Create dir e.g /home/user*/eclipse-deps/ and copy jsp-api.jar from */tomcat/lib dir
    2. In the Eclipse go to project properties->build path, and create new "UserLibrary" eg. IdeDeps.
    3. Include /home/user/eclipse-deps/ in IdeDeps library, and include user library in all projects which are dependent on jsp-api.jar (in classpath: < classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/IdeDeps"/ >)

    You can do that for all *.jars which should not be deployed, but eclipse need it for validation purpose.

    0 讨论(0)
  • 2021-01-30 09:05

    I had the same problem, but both jsp-api.jar and servlet-api.jar were already in build path. Disabling JSP Syntax Validator didn't help as well.

    Instead, I had to disable JSP Content Validator, leaving the syntax validator enabled. I still have underlined code in my JSP but no red cross indicating compiling error and that's the point :)

    0 讨论(0)
  • 2021-01-30 09:06

    In order to fix:
    - javax.servlet.jsp.* needs jsp-api.jar
    - javax.servlet.http.* needs servlet-api.jar

    You need to add these libraries to Java Build path in project setup. These libraries can be found in tomcat/lib directory (for Tomcat 6.0).

    0 讨论(0)
  • 2021-01-30 09:06

    Try to check your project classpath. It looks like you don't have the JSP library in your project (hence the "JspException cannot be resolved"), or that your library version isn't the same as the JSP compiler version.

    The library is included by default in the application server on which you deploy your app, so the code runs perfectly when deployed. However, if the Eclipse internal compiler is missing a library (or have an incorrect version), the Eclipse editor shows you error that doesn't exists in app server.

    0 讨论(0)
  • 2021-01-30 09:06

    I also see the same problem during I shift to Maven (with m2e), get error like "javax.servlet.http cannot be resolved" and some Spring tags undefined warning. finally I find it's because java version (v1.6) in my build configuration is not same as in facets configuration (v1.7). after change v1.7 to v1.6 the problem disappear.

    0 讨论(0)
提交回复
热议问题