jsp中equals()方法比较字符串出错
请教一下各位,最近碰到一个问题,我在jsp中用equals()方法判断字符串是否相等总是出错,请大家帮忙看一下。
代码:
<%
request.setCharacterEncoding("gb2312");
String b=request.getParameter("hiddenField");
if(b.equals("sub")){
String s=request.getParameter("select");
String sql="";
if(s.equals("身份证")) {
sql="select * from UserInf where Identification='"+request.getParameter("num")+"'";
}
else sql="select * from UserInf where CardNum='"+request.getParameter("num")+"'";
try{
User u=User.getUser(sql);
session.setAttribute("user",u);
}
catch(UserNotFoundException e){
e.printStackTrace();
}
}
%>
color=#FF0000]错误:[[/color]
exception
org.apache.jasper.JasperException: An exception occurred processing JSP page /admin/CardLost.jsp at line 55
52: <%
53: request.setCharacterEncoding("gb2312");
54: String b=request.getParameter("hiddenField");
55: if(b.equals("sub")){
56: String s=request.getParameter("select");
57: String sql="";
58: if(s.equals("身份证")) {
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:505)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause
java.lang.NullPointerException