在文件目录中找不到包

时间:2016-06-05 10:58:39

标签: java

我的文件夹结构--com --example --model - > BeerExpert.java --web - > BeerExpert.java的BeerSelect.java代码

package com.example.model; import java.util.*;

public class BeerExpert{ public List getBrands(String color) { List brands = new ArrayList(); if(color.equals("black")) { brands.add("jack amber"); brands.add("red moose"); } else { brands.add("jail pale ale"); brands.add("gout stout"); } return(brands); } }

code in BeerSelect.java package com.example.web; import com.example.model.; import javax.servlet.; import javax.servlet.http.; import java.io.;

public class BeerSelect extends HttpServlet{

public void doPost(HttpServletRequest request,HttpServletResponse response)throws IOException,ServletException{

    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    out.println("Beer selection advice");
    String c = request.getParameter("color");
    out.println("got beer color is"+c); 
    BeerExpert be= new BeerExpert();
    List result= be.getBrands(c);
    Iterator i = result.iterator();
    while(i.hasNext()){
        out.println("<br>try:" + i.next());
    }

}
}

当我尝试编译BeerSelect.java时,我得到了以下结果

E:\MyProjects\beerV1>javac -d classes src/com/example/web/BeerSelect.java src\com\example\web\BeerSelect.java:2: error: package com.example.model does not exist import com.example.model.*; ^ src\com\example\web\BeerSelect.java:16: error: cannot find symbol BeerExpert be= new BeerExpert(); ^ symbol: class BeerExpert location: class BeerSelect src\com\example\web\BeerSelect.java:16: error: cannot find symbol BeerExpert be= new BeerExpert(); ^ symbol: class BeerExpert location: class BeerSelect src\com\example\web\BeerSelect.java:17: error: cannot find symbol List result= be.getBrands(c); ^ symbol: class List location: class BeerSelect src\com\example\web\BeerSelect.java:18: error: cannot find symbol Iterator i = result.iterator(); ^ symbol: class Iterator location: class BeerSelect 5 errors

0 个答案:

没有答案