我在打开项目时遇到两个非常奇怪的错误。如果我打开登录页面并不断刷新它,错误消息会在下面两个之间交替出现。
我明白了:
org.apache.jasper.JasperException: /WEB-INF/pages/LandingPage.jsp (line: 2, column: 0) The absolute uri: http://www.springframework.org/security/tags cannot be resolved in either web.xml or the jar files deployed with this application
或者这个:
HTTP Status 500 - java.lang.ClassNotFoundException: org.apache.jsp.WEB_002dINF.pages.LandingPage_jsp
到底发生了什么?
最佳答案
因为:
原因1:解析JSP文件错误。例如: 错误 JSP 页面(由于语法错误或缺少依赖项):
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page session="false" %>
<html>
<head>
<title>Home</title>
</head>
<body>
<h1>Hello world!</h1>
<p>The time on server is ${serverTime}.</p>
</body>
</html>
改正:
<%@page session="false" %>
<html>
<head>
<title>Home</title>
</head>
<body>
<h1>Hello world!</h1>
<p>The time on server is ${serverTime}.</p>
</body>
</html>
原因 2:缺少依赖项。通过添加这些依赖项来修复它:
<dependency>
<groupId>javax.servlet.jsp.jstl</groupId>
<artifactId>jstl-api</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.2</version>
<scope>provided</scope>
</dependency>
你必须像上面那样设置scope
。
关于spring - java.lang.ClassNotFoundException : org. apache.jsp.WEB_002dINF.pages.LandingPage_jsp,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25360722/
相关文章:
java - Spring REST Controller 返回带有空数据的 JSON
java - 无法使用 JAXB org.springframework.oxm.Unmarshal
java - JtaTransactionManager 和 ChainedTransactionM
java - STS Spring 与 Roo 和 Maven - 太慢了?
java - AsyncContext 响应与原始传入请求不匹配?
spring - IntelliJ + Tomcat + Spring-Loaded
spring - Spring 和 Java EE 中的 @PersistenceContext E
java - 如何使用 RestTemplate 为每个请求设置 RequestConfigurat