嗨,我正在尝试用tomcat编译一个简单的jsp文件,但我一直有这个错误信息
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 13 in the jsp file: /WebContent/test.jsp
Member cannot be resolved to a type
10: <body>
11: <%
12: //MyBatisDao myDao = new MyBatisDao();
13: List<Member> list; // = myDao.func("test");
14: //out.println("Result list= " + list);
15: %>
16: </body>
Run Code Online (Sandbox Code Playgroud)
test.jsp(在Webcontent上)
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="pageNumber.*, java.util.*, java.io.*" %>
<!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=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
List<Member> list;
%>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
Member.java
package pageNumber;
public class Member {
private String id;
private String pw;
private int point;
private int lvl;
public Member() {}
public Member(String id, String pw, int point, int lvl) {
this.id = id;
this.pw = pw;
this.point = point;
this.lvl = lvl;
}
public String getId() { return id; }
public void setId(String id) { this.id = id; }
public String getPw() { return pw; }
public void setPw(String pw) { this.pw = pw; }
public int getPoint() { return point; }
public void setPoint(int point) { this.point = point; }
public int getLvl() { return lvl; }
public void setLvl(int lvl) { this.lvl = lvl; }
public String toString() {
return "ID= " + id + ", PW= " + pw + ", POINT= " + point + ", LVL= " + lvl;
}
Run Code Online (Sandbox Code Playgroud)
}
据我所知,我遇到了这个问题,因为我的tomcat找不到类文件,所以我把我的类文件放在了
但没有一个成功.有帮助吗?
编辑:从我更改我的导入声明后
<%@ page import="pageNumber.*, java.util.*, java.io.*" %>
Run Code Online (Sandbox Code Playgroud)
至
<%@ page import="java.util.List, pageNumber.Member" %>
Run Code Online (Sandbox Code Playgroud)
它实际上给了我一种新的错误:
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 15 in the generated java file
Only a type can be imported. pageNumber.Member resolves to a package
An error occurred at line: 12 in the jsp file: /WebContent/test.jsp
Member cannot be resolved to a type
9: </head>
10: <body>
11: <%
12: List<Member> list; // = myDao.func("test");
13: %>
14: </body>
15: </html>
Run Code Online (Sandbox Code Playgroud)
将您的会员类包含到您的 jsp 中:
<%@ page import="pageNumber.*, java.util.*, java.io.*,yourMemberPackage.Member" %>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
147155 次 |
| 最近记录: |