当前位置: 代码迷 >> Java Web开发 >> cannot be resolved to a type,该如何处理
  详细解决方案

cannot be resolved to a type,该如何处理

热度:1038   发布时间:2016-04-17 10:24:00.0
cannot be resolved to a type
老兄; 我在显示页面(.jsp)添加<%CustomerBean bean1=(CustomerBean)session.getAttribute("currentCustomer");%>这句话时会出现这样的提示:CustomerBean cannot be resolved to a type
我很急的,谢谢!

我是从servlet跳到到这个页面的以下是servlet的代码;
public class BankServlet extends HttpServlet {

/**
* The doGet method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to get.

* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
HttpSession session=request.getSession();
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String userID=request.getParameter("id");
BankModel bankmodel=new BankModel();
List customerlist=null;
CustomerBean currentCustomer=new CustomerBean();//当前的用户
double balance=0;//当前用户的余额
customerlist= bankmodel.getCustomers();
String id;
if(userID!=null){
for(int i=0;i<customerlist.size();i++){
CustomerBean bean=(CustomerBean)customerlist.get(i);
id=bean.getUserID();//获取id
if(id.equals(userID)){
balance=bean.getBalance();
String username=bean.getUserName();
currentCustomer.setUserName(username);
currentCustomer.setBalance(balance);//double
currentCustomer.setUserID(id);
session.setAttribute("currentCustomer",currentCustomer );
break;
}


}
}
else 
response.sendRedirect("UnknowCustomer.jsp");

if(balance<0){
response.sendRedirect("NegativeBalance.jsp");
}
else if(balance>0&&balance<100000){
response.sendRedirect("NormalBalance.jsp");
}
else 
response.sendRedirect("HighCustomer.jsp");



}

}




------解决方案--------------------
没有导入相应的类吧
<%@ page import="xxx.xxx.xxx.CustomerBean" %>
------解决方案--------------------
或者楼主用jsp标签
<jsp:useBean id="currentCustomer" scope="session" class="CustomerBean.java的路径"/>
这样也要把上面CustomerBean.java的路径导入的,方法已经说了
------解决方案--------------------
探讨
我是在默认的包下建的CustomerBean.java,在 jsp的页面中是怎么样导入的?
  相关解决方案