0
嗨,我檢查頁指令,但擴展頁指令不工作。
下面我jsp頁面
擴展頁面指令不工作
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page extends="javapackage.TestClass" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>Hai
<% out.println(show()); %>
</body>
</html>
和我的課是
package javapackage;
public class TestClass {
public String show(){
return "Welcome Prasad";
}
}
它給了我500錯誤
例外
org.apache.jasper.JasperException: java.lang.ClassCastException: org.apache.jsp.first_jsp cannot be cast to javax.servlet.Servlet
org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:177)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
root cause
java.lang.ClassCastException: org.apache.jsp.first_jsp cannot be cast to javax.servlet.Servlet
org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:172)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
即使我試圖與類擴展Http Servlet,但沒有用。所以任何人都請幫助我。我正在使用Tomcat 7
謝謝