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类中的方法,跪求大佬解决,谢谢了 展开
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类中的方法,跪求大佬解决,谢谢了 展开
4个回答
展开全部
建议你上错误报告。
我这边简单看了一下,是不是空指针错误?
如果customer是null的话,getAccount我不确定是不是会报错。
我这边简单看了一下,是不是空指针错误?
如果customer是null的话,getAccount我不确定是不是会报错。
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
边种无法调整的话,我觉得还是应该找专家技术人员了。这方面的应用专家完全可以把它拿下来。其他的老百姓。可以说是无解。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询