2017-06-26 7 views
0

PWC6197: An error occurred at line: 15 in the jsp file: /searchresult.jsp PWC6199: Generated servlet error: cannot find symbol symbol: class Food location: class org.apache.jsp.searchresult_jsp内部サーバーエラー500データベースと何か関係はありますか?どうすれば解決できますか?

PWC6197: An error occurred at line: 15 in the jsp file: /searchresult.jsp PWC6199: Generated servlet error: cannot find symbol symbol: class Food location: class org.apache.jsp.searchresult_jsp

PWC6197: An error occurred at line: 22 in the jsp file: /searchresult.jsp PWC6199: Generated servlet error: cannot find symbol symbol: class Food location: class org.apache.jsp.searchresult_jsp

これは私のコードを何らかの理由で実行した後のものです。それは私のデータベースとは何かを持っていますか?そうでない場合は、私はこれは、あなたは

を入力し、あなたのJSPファイルにインポートを追加する必要があり、私の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; 
    } 

} 

答えて

1

ある

<!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> 

それを解決するのですかパッケージの代わりに関連パッケージ名

<%@ page import="sg.edu.nyp.Food " %> 

フードクラスがコンテキスト内に存在することを確認してください。

使用Tomcatが/sg/edu/nyp/Food.class

の下にWEB-INF /クラス/ SG/EDU/NYP/Food.classまたはjarファイル内のWEB-INF/libにあるべき場合
+0

ああ私はその上にそれを追加することを忘れていた – user8214956

+0

それはクラスを見つけられませんでした。それは瓶の中にいますか?容器に入っている瓶ですか? – user7294900

+0

申し訳ありません瓶がどういう意味ですか? – user8214956

関連する問題