org.apache.jasper.JasperException: Unable to compile class for JSP: 解决办法
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了org.apache.jasper.JasperException: Unable to compile class for JSP: 解决办法相关的知识,希望对你有一定的参考价值。
org.apache.jasper.JasperException: Unable to compile class for JSP: An error occurred at line: 3 in the jsp file: /ch3-4-include1.jsp Duplicate local variable path 1: <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> 2: <% 3: String path = request.getContextPath(); 4: String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; 5: %> 6: An error occurred at line: 4 in the jsp file: /ch3-4-include1.jsp Duplicate local variable basePath 1: <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> 2: <% 3: String path = request.getContextPath(); 4: String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; 5: %> 6: 7: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
源码:
<!--ch3-4-include1.jsp-->
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<html>
<head>
<title>被include包含的文件</title>
</head>
<body>
<h1>Hello World!</h1>
</body>
</html>
<!--ch3-4-include2.jsp-->
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<html>
<head>
<base href="<%=basePath%>">
<title>include指令实例</title>
</head>
<body>
<center>
现在的日期和时间是:<%=new Date() %>
<hr>
<%@ include file="ch3-4-include1.jsp" %>
</center>
</body>
</html>
这个错误是在我的这个代码里面是ch3-4-include1.jsp文件里多了 import="java.util.*"
然后把这个import="java.util.*"删除就不报错误了。再把其他多余的代码删掉
2: <% 3: String path = request.getContextPath(); 4: String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; 5: %> 6: 7: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
类似这些的删掉!!
以上是关于org.apache.jasper.JasperException: Unable to compile class for JSP: 解决办法的主要内容,如果未能解决你的问题,请参考以下文章