JSP导入类导致错误

时间:2017-07-04 13:31:33

标签: jsp ubuntu tomcat8 geany

这是我第一次尝试使用JSP。我正在使用TOMCAT8和Geany来写。我将应用程序文件夹放在/var/lib/tomcat8/webapps/Jproject/var/lib/tomcat8/webapps/Jproject/WEB-INF/classes中的类中。

我的班级文件/var/lib/tomcat8/webapps/Jproject/WEB-INF/classes/test.class是;

public class test
{
public static void PP()
{
System.out.println("yoyo");
}
}

和我的index.jsp (/var/lib/tomcat8/webapps/Jproject/index.jsp)是;

<%@ page import="Jproject.test.*" %> 
<DOCTYPE! html> 
<html> 
<head>
<title>Project</title> 
</head> 
<body> 
<%  String x = "java";
    out.println("Hello " + x + "Worlds");   
test.PP(); %> 
</body> 
</html>

当我在浏览器http://localhost:8080/Jproject/上运行时,我收到以下错误;

HTTP Status 500 - Unable to compile class for JSP:

type Exception report

message Unable to compile class for JSP:

description The server encountered an internal error that prevented it from fulfilling this request.

exception

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

An error occurred at line: 12 in the jsp file: /index.jsp
test cannot be resolved
9:  String x = "java";
10: 
11:     out.println("Hello " + x + "Worlds");
12:     test.PP();
13: %>
14: </body>
15: </html>


Stacktrace:
    org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:103)
    org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:198)
    org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:449)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:361)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:336)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:323)
    org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:585)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:363)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:401)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:345)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
note The full stack trace of the root cause is available in the Apache Tomcat/8.0.32 (Ubuntu) logs.

Apache Tomcat/8.0.32 (Ubuntu)

我做错了什么?谢谢你的帮助!

1 个答案:

答案 0 :(得分:0)

你必须在src文件夹下创建类而不是<style> .input_strips { font-family: monospace; <!--change the font size this will change the input cursor and the text box--> font-size: 30px; } </style> 文件夹,并在WEB-INF文件夹下创建jsp文件。

相关问题