JavaServlet无法调用javaBean中的类? 5

JavaBean代码packagemybean.data;publicclassCustomerLogin{privateStringaccount;privateStr... JavaBean代码

package mybean.data;
public class CustomerLogin {
private String account;
private String password;
private String back;
private boolean fg;
public void setAccount(String account){
this.account=account;
}
public String getAccount(){
return this.account;
}
public void setPassword(String password){
this.password=password;
}
public String getPassword(){
return this.password;
}
public void setBack(String back){
this.back=back;
}
public String getBack(boolean fg){
return this.back;
}
public void setFg(boolean fg){
this.fg=fg;
}
public boolean isFg(){
return this.fg;
}
}
javaServlet代码
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package myservlet.control;
import mybean.data.*;
import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class CustomerLogin extends HttpServlet {
public void init(ServletConfig config) throws ServletException{
super.init(config);
try{
Class.forName("com.mysql.jdbc.Driver");
}
catch(Exception e){}
}
public String handleString(String b){
try{
byte bb[]=b.getBytes("iso-8859-1");
}catch(Exception e){
}
return b;
}
public void doPost(HttpServletRequest request,HttpServletResponse response)
throws ServletException,IOException{
Connection con;
Statement sql;
CustomerLogin customer=null;
String back="";
HttpSession session=request.getSession(true);
try{
customer=(CustomerLogin)session.getAttribute("CustomerLogin");
if(customer==null){
customer= new CustomerLogin();
session.setAttribute("CustomerLogin",customer);
}
}catch(Exception ee){
customer=new CustomerLogin();
session.setAttribute("CustomerLogin",customer);
}
String account=request.getParameter("account").trim();
String password=request.getParameter("password").trim();
boolean ok=false;
account=handleString(account);
password=handleString(password);
if(ok=true&&account.equals(customer.getAccount()))
{
}
}

}
然后错误就错在if(ok=true&&account.equals(customer.getAccount()))这段代码,getAccount()这个方法调用不了,一直提示找不到符号,但是我的JavaBean类中是由这个方法的,前面都没有出错就这儿错误,就是调用不了Bean类中的方法,跪求大佬解决,谢谢了
展开
 我来答
greatReanswer
高粉答主

2019-12-18 · 醉心答题,欢迎关注
知道大有可为答主
回答量:1.9万
采纳率:89%
帮助的人:654万
展开全部
你这个有点多,没仔细看,你在运行代码时应该先使用输出函数测试这一行,其次,我看你获取account的值,但你没设置过这个值啊,其次你程序的判断条件,无论怎么样,你都创建对象,哪和没条件没区别。
更多追问追答
追问
我那个getAccount方法是用来和之前那个从jsp页面获取来的account的值做比较的
追答
主要我看你新建了一个对象
说说枫叶国
2019-12-18 · TA获得超过852个赞
知道小有建树答主
回答量:699
采纳率:71%
帮助的人:85.9万
展开全部
建议你上错误报告。

我这边简单看了一下,是不是空指针错误?
如果customer是null的话,getAccount我不确定是不是会报错。
本回答被网友采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
匿名用户
2019-12-18
展开全部
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
满意pjp

2019-12-18 · 投资理财,银行业务以及保险行业。
满意pjp
采纳数:12739 获赞数:17947

向TA提问 私信TA
展开全部
边种无法调整的话,我觉得还是应该找专家技术人员了。这方面的应用专家完全可以把它拿下来。其他的老百姓。可以说是无解。
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 1条折叠回答
收起 更多回答(2)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式