Unable to compile class for JSP: 求助
报错:org.apache.jasper.JasperException:UnabletocompileclassforJSP:Anerroroccurredatline...
报错:
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 20 in the jsp file: /error.jsp
exception cannot be resolved
17: <div id="main">
18: <h1><fmt:message key="errorPage.heading"/></h1>
19: <%@ include file="/common/messages.jsp" %>
20: <% if (exception != null) { %>
21: <pre><% exception.printStackTrace(new java.io.PrintWriter(out)); %></pre>
22: <% } else if ((Exception)request.getAttribute("javax.servlet.error.exception") != null) { %>
23: <pre><% ((Exception)request.getAttribute("javax.servlet.error.exception"))
An error occurred at line: 21 in the jsp file: /error.jsp
exception cannot be resolved
18: <h1><fmt:message key="errorPage.heading"/></h1>
19: <%@ include file="/common/messages.jsp" %>
20: <% if (exception != null) { %>
21: <pre><% exception.printStackTrace(new java.io.PrintWriter(out)); %></pre>
22: <% } else if ((Exception)request.getAttribute("javax.servlet.error.exception") != null) { %>
23: <pre><% ((Exception)request.getAttribute("javax.servlet.error.exception"))
24: .printStackTrace(new java.io.PrintWriter(out)); %></pre>
源码:
<html>
<head>
<title><fmt:message key="errorPage.title"/></title>
<link rel="stylesheet" type="text/css" media="all" href="<c:url value='/styles/${appConfig["csstheme"]}/theme.css'/>" />
</head>
<body id="error">
<div id="page">
<div id="content" class="clearfix">
<div id="main">
<h1><fmt:message key="errorPage.heading"/></h1>
<%@ include file="/common/messages.jsp" %>
<% if (exception != null) { %>
<pre><% exception.printStackTrace(new java.io.PrintWriter(out)); %></pre>
<% } else if ((Exception)request.getAttribute("javax.servlet.error.exception") != null) { %>
<pre><% ((Exception)request.getAttribute("javax.servlet.error.exception"))
.printStackTrace(new java.io.PrintWriter(out)); %></pre>
<% } %>
</div>
</div>
</div>
</body>
</html>
求助····
直接提出解决方案··· 展开
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 20 in the jsp file: /error.jsp
exception cannot be resolved
17: <div id="main">
18: <h1><fmt:message key="errorPage.heading"/></h1>
19: <%@ include file="/common/messages.jsp" %>
20: <% if (exception != null) { %>
21: <pre><% exception.printStackTrace(new java.io.PrintWriter(out)); %></pre>
22: <% } else if ((Exception)request.getAttribute("javax.servlet.error.exception") != null) { %>
23: <pre><% ((Exception)request.getAttribute("javax.servlet.error.exception"))
An error occurred at line: 21 in the jsp file: /error.jsp
exception cannot be resolved
18: <h1><fmt:message key="errorPage.heading"/></h1>
19: <%@ include file="/common/messages.jsp" %>
20: <% if (exception != null) { %>
21: <pre><% exception.printStackTrace(new java.io.PrintWriter(out)); %></pre>
22: <% } else if ((Exception)request.getAttribute("javax.servlet.error.exception") != null) { %>
23: <pre><% ((Exception)request.getAttribute("javax.servlet.error.exception"))
24: .printStackTrace(new java.io.PrintWriter(out)); %></pre>
源码:
<html>
<head>
<title><fmt:message key="errorPage.title"/></title>
<link rel="stylesheet" type="text/css" media="all" href="<c:url value='/styles/${appConfig["csstheme"]}/theme.css'/>" />
</head>
<body id="error">
<div id="page">
<div id="content" class="clearfix">
<div id="main">
<h1><fmt:message key="errorPage.heading"/></h1>
<%@ include file="/common/messages.jsp" %>
<% if (exception != null) { %>
<pre><% exception.printStackTrace(new java.io.PrintWriter(out)); %></pre>
<% } else if ((Exception)request.getAttribute("javax.servlet.error.exception") != null) { %>
<pre><% ((Exception)request.getAttribute("javax.servlet.error.exception"))
.printStackTrace(new java.io.PrintWriter(out)); %></pre>
<% } %>
</div>
</div>
</div>
</body>
</html>
求助····
直接提出解决方案··· 展开
展开全部
对于前面各位的的回答,我不甚同意,问题处在exception
但是exception确实是JSP中的内置对象,只是在普通的JSP页面无法直接使用
需要在文件的头部进行设置 isErrorPage="true"
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" isErrorPage="true"%>
而JSP中默认是false
这样servlet容器就为为你初始化exception内置对象
但是exception确实是JSP中的内置对象,只是在普通的JSP页面无法直接使用
需要在文件的头部进行设置 isErrorPage="true"
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" isErrorPage="true"%>
而JSP中默认是false
这样servlet容器就为为你初始化exception内置对象
展开全部
exception != null 这句中的对象exception在使用之前没有声明。 所以找不到exception编译不通过
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
JSP有内置的对象,如request,response,out,session等,它们都是JSP对应的Servlet内部已经定义好的对象,可是exception不是内置对象。对象必须先定义才能使用,否则编译时出错“xxxxx cannot be resolved”。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询