java.lang.NullPointerException
各位大神,求解啊,急!源码:booleanisLD=true;for(inti=0;i<logname.length();i++){charc=logname.charA...
各位大神,求解啊,急!
源码:
boolean isLD = true;
for (int i = 0; i < logname.length(); i++) {
char c = logname.charAt(i);
if (!((c <= 'z' && c > 'a') || (c <= 'z' && c > 'A') || (c <= '9' && c >= '0')))
isLD = false;
}
boolean boo = logname.length() > 0 && password.length() > 0 && isLD;
String backNews = "";
try {
con = DriverManager.getConnection(uri);
String insertCondition = "INDERT INTO user VALUES(?,?,?,?,?)";
sql = con.prepareStatement(insertCondition);
if (boo) {
sql.setString(1, handleString(logname));
sql.setString(2, handleString(password));
int m = sql.executeUpdate();
if (m != 0) {
backNews = "注册成功";
userBean.setBackNews(backNews);
userBean.setBackNews(logname);
}
} else {
backNews = "信息填写不完整或名字中有非法字符";
userBean.setBackNews(backNews);
}
con.close();
} catch (SQLException exp) {
backNews = "该会员名已被使用,请您更换名字" + exp;
userBean.setBackNews(backNews);
}
RequestDispatcher dispatcher = request
.getRequestDispatcher("inputRegisterMess.jsp");
java.lang.NullPointerException
at myservlet.control.HandleRegister.doPost(HandleRegister.java:29)
at myservlet.control.HandleRegister.doGet(HandleRegister.java:83)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
重新整理下源代码:
错误提示:
java.lang.NullPointerException
at myservlet.control.HandleRegister.doPost(HandleRegister.java:29)
at myservlet.control.HandleRegister.doGet(HandleRegister.java:83)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) 展开
源码:
boolean isLD = true;
for (int i = 0; i < logname.length(); i++) {
char c = logname.charAt(i);
if (!((c <= 'z' && c > 'a') || (c <= 'z' && c > 'A') || (c <= '9' && c >= '0')))
isLD = false;
}
boolean boo = logname.length() > 0 && password.length() > 0 && isLD;
String backNews = "";
try {
con = DriverManager.getConnection(uri);
String insertCondition = "INDERT INTO user VALUES(?,?,?,?,?)";
sql = con.prepareStatement(insertCondition);
if (boo) {
sql.setString(1, handleString(logname));
sql.setString(2, handleString(password));
int m = sql.executeUpdate();
if (m != 0) {
backNews = "注册成功";
userBean.setBackNews(backNews);
userBean.setBackNews(logname);
}
} else {
backNews = "信息填写不完整或名字中有非法字符";
userBean.setBackNews(backNews);
}
con.close();
} catch (SQLException exp) {
backNews = "该会员名已被使用,请您更换名字" + exp;
userBean.setBackNews(backNews);
}
RequestDispatcher dispatcher = request
.getRequestDispatcher("inputRegisterMess.jsp");
java.lang.NullPointerException
at myservlet.control.HandleRegister.doPost(HandleRegister.java:29)
at myservlet.control.HandleRegister.doGet(HandleRegister.java:83)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
重新整理下源代码:
错误提示:
java.lang.NullPointerException
at myservlet.control.HandleRegister.doPost(HandleRegister.java:29)
at myservlet.control.HandleRegister.doGet(HandleRegister.java:83)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |