无法编译JSP HTTP Status 500的类

时间:2014-08-29 07:31:48

标签: java jsp

jsp文件中的第14行:/jsp1.jsp发生错误 Package.CustomTag无法解析为类型

堆栈跟踪:

org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:451)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:356)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:334)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:321)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:592)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:723)  

JSP文件jsp1.jsp

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib prefix="ex" uri="/WEB-INF/newtag"%>
<!DOCTYPE html>

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Custom Tags</title>
</head>
<body>
    <ex:CustomTag/>     // LINE 14
</body>
</html>

TLD文件

<?xml version="1.0" encoding="UTF-8"?>
<taglib version="2.1" xmlns="http://java.sun.com/xml/ns/javaee"         
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee  
http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_2_1.xsd">    
<tlib-version>1.0</tlib-version>
<short-name>Example TLD</short-name>
<uri>/WEB-INF/newtag</uri>

<tag>
<name>CustomTag</name>
<tag-class>Package.CustomTag</tag-class>
<body-content>empty</body-content>
</tag>
</taglib>

处理程序类

package Package;
import java.io.IOException; 
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.SimpleTagSupport;

public class CustomTag extends SimpleTagSupport 
{

@Override
public void doTag() throws JspException, IOException
{
    JspWriter out = getJspContext().getOut();
   out.write("This is a custom tag");
}

}

0 个答案:

没有答案