我有一个从类目录中的包文件夹导入的 jsp 文件。当我尝试使用它时,我收到“无法编译”和“无法解析为类型”错误。这是我的代码。
<%@ page language="java" import="cs5530.*" %>
<html>
<head>
<script type="text/javascript">
function showInvalid()
{
document.getElementById("invalid").style.display = 'block';
document.getElementById("loginForm").reset();
}
</script>
</head>
<body>
<p>Welcome to FlixNet. Sign In</p>
<form name="loginForm" method="post" action="index.jsp">
User Name: <input type="text" name="username"><br>
Password: <input type="Password" name="password"><br>
<input type="submit" value="Submit">
<div id="invalid" style="display:none">
<p>Invalid username or password</p>
</div>
</form>
<%
Connector con = new Connector();
con.closeConnection();
%>
</body>
</html>
这是错误
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 23 in the jsp file: /index.jsp
Connector cannot be resolved to a type
20: </div>
21: </form>
22: <%
23: Connector con = new Connector();
24: con.closeConnection();
25: %>
26: </body>
An error occurred at line: 23 in the jsp file: /index.jsp
Connector cannot be resolved to a type
20: </div>
21: </form>
22: <%
23: Connector con = new Connector();
24: con.closeConnection();
25: %>
26: </body>
Stacktrace:
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:439)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:334)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:312)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:299)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:589)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
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:717)
这是我的文件结构
public_html
index.jsp
|WEB-INF
|classes
mysql.jar
|cs5530
Connector.java
Connector.class
other java and class files.
我的连接器类在包 cs5530 下,所以这不是问题。连接器类是我测试过的一个简单的数据库连接器类,它可以工作。