作业帮 > 综合 > 作业

模糊查询,查中文和英文报错,但是可以查数字

来源:学生作业帮 编辑:大师作文网作业帮 分类:综合作业 时间:2024/11/10 16:26:13
模糊查询,查中文和英文报错,但是可以查数字
服务类
public ArrayList queryXm(String Fname){
\x05\x05 \x05\x05
\x05\x05 \x05\x05Fname = "%"+Fname+"%";
\x05\x05 \x05\x05ArrayList al = null
\x05\x05 \x05\x05try {
\x05\x05 \x05 String sql = "select * from oldcustomer where Fname like "
\x05\x05 \x05 al = (ArrayList)jt.query(sql,new OldRowMapper(),Fname);
\x05\x05 \x05 } catch (DataAccessException e) {
\x05\x05 \x05 e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
\x05\x05 \x05 }
\x05\x05 \x05\x05return al;
\x05\x05 \x05}
报错
type Exception report
message java.lang.NullPointerException
description The server encountered an internal error that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException:java.lang.NullPointerException\x05org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:502)\x05org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:430)\x05org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)\x05org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)\x05javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
root cause
模糊查询,查中文和英文报错,但是可以查数字
模糊查询需要单引号.Fname = "'%"+Fname+"%'";