PWC6197:jsp文件中第15行发生错误: /searchresult.jsp PWC6199:生成的servlet错误:找不到符号 symbol:class食物位置:类org.apache.jsp.searchresult_jsp
PWC6197:jsp文件中第15行发生错误: /searchresult.jsp PWC6199:生成的servlet错误:找不到符号 symbol:class食物位置:类org.apache.jsp.searchresult_jsp
PWC6197:jsp文件中第22行发生错误: /searchresult.jsp PWC6199:生成的servlet错误:找不到符号 symbol:class食物位置:类org.apache.jsp.searchresult_jsp
这是我在运行代码之后得到的任何想法为什么?它与我的数据库有什么关系吗?如果不是我如何解决它
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p><b>Search Results</b></p>
<hr/>
<p>Search results for <b>"<%=session.getAttribute("searchterm")%>"</b></p>
<hr/>
<tr><th>Name</th><th>Price</th><th>Restaurant</th></tr>
<%
List<Food> searchResult = (List<Food>)
session.getAttribute("searchresult");
if(searchResult == null || searchResult.size() <= 0)
{
%>
<tr><td colspan="3">(No result is found)</td></tr>
<%
}
else
{
for(Food food : searchResult)
{
%>
<tr>
<td><%=food.getItemName()%></td>
<td><%=food.getprice()%></td>
<td><%=food.getrestaurant()%></td>
</tr>
<%
}
}
%>
<hr/>
</body>
</html>
这是我的Food.Java
package sg.edu.nyp;
import java.io.Serializable;
/**
*
* @author VN7-517G-73XW
*/
public class Food implements Serializable{
public static final long serialVersionUID = -1L;
private String itemName;
private double price;
private String restaurant;
public Food()
{
}
public String getItemName() {
return itemName;
}
public double getPrice() {
return price;
}
public String getRestaurant() {
return restaurant;
}
public void setItemName(String itemName) {
this.itemName = itemName;
}
public void setPrice(double price) {
this.price = price;
}
public void setRestaurant(String restaurant) {
this.restaurant = restaurant;
}
}
答案 0 :(得分:1)
您必须将导入添加到JSP文件
输入相关的包名而不是[包]
<%@ page import="sg.edu.nyp.Food " %>
并确保Food类存在于上下文中。
如果使用tomcat应该在/sg/edu/nyp/Food.class下的jar-WEB / INF / classes / sg / edu / nyp / Food.class或WEB-INF / lib中