Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/397.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java SpringWeb应用程序错误_Java_Jsp_Spring Mvc - Fatal编程技术网

Java SpringWeb应用程序错误

Java SpringWeb应用程序错误,java,jsp,spring-mvc,Java,Jsp,Spring Mvc,此运行时错误发生在我的spring mvc项目中。目标服务器apache tomcat 8.0。你能帮我解决这个问题吗 org.apache.jasper.JasperException: Unable to compile class for JSP: An error occurred at line: [31] in the generated java file: [C:\Users\mehrdad\workspace\.metadata\.plugins\org.eclipse.w

此运行时错误发生在我的spring mvc项目中。目标服务器apache tomcat 8.0。你能帮我解决这个问题吗

org.apache.jasper.JasperException: Unable to compile class for JSP: 

An error occurred at line: [31] in the generated java file: [C:\Users\mehrdad\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\work\Catalina\localhost\CPNC\org\apache\jsp\pages\home_jsp.java]
The method getJspApplicationContext(ServletContext) is undefined for the type JspFactory

An error occurred at line: [42] in the generated java file: [C:\Users\mehrdad\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\work\Catalina\localhost\CPNC\org\apache\jsp\pages\home_jsp.java]
The method getDispatcherType() is undefined for the type HttpServletRequest

Stacktrace:
    org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:103)
    org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:199)
    org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:450)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:361)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:336) 
这是home.jsp:

<?xml version="1.0" encoding="ISO-8859-1" ?>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Home page</title>
</head>
<body>
<h1>Home page</h1>
<p>This is Home page. It's available for all users.<br/>
<a href="${pageContext.request.contextPath}/sec/moderation.html">Moderation page</a><br/>
<a href="${pageContext.request.contextPath}/admin/first.html">First Admin page</a><br/>
<a href="${pageContext.request.contextPath}/admin/second.html">Second Admin page</a><br/>
</p>
</body>
</html>

主页
主页
这是主页。它可供所有用户使用。




从生成的WAR文件中删除库
javax.servlet api
servlet api
jsp api
jstl
。这些库应该在编译时使用,但不应该包含在战争档案中。编译JSP文件的服务器(例如Tomcat)提供这些依赖项。您的库优先于服务器提供的库,这会导致错误


如果您使用的是Maven或Gradle,请将依赖项的范围设置为
提供的
值。

这可能是类路径中存在多个(冲突的)servlet api JAR的问题。检查一下lib目录,确保您使用的是3+api版本。您能在war中列出jar文件吗?此图显示了我的jar文件:一般来说,使用JSTL标记比手动预挂起上下文根更好。除了已经建议的错误之外,没有关于错误的线索。@mehrdadolghafari最好在问题本身中将依赖项列为文本。可能对阅读你的问题的人有用。