Topic: java.lang.NullPointerException怎么解决 |
Print this page |
1.java.lang.NullPointerException怎么解决 | Copy to clipboard |
Posted by: liujing319 Posted on: 2005-09-06 12:06 我的JSP出现下面的错误:请各位帮忙看看 exception org.apache.jasper.JasperException org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:372) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) root cause java.lang.NullPointerException org.apache.jsp.liangdichaxun_jsp._jspService(liangdichaxun_jsp.java:100) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) 怎么回事?我的JSP 代码如下 <%@ include file="head.jsp"%> <form action="liangdichaxun.jsp" method="post"> <input type="text" name="qishidi"> <input type="text" name="mudidi"> <input type="submit" value="chaxun"> <% String qishi,mudi; int p=2; String qishidi= new String (request.getParameter("qishidi").getBytes("ISO-8859-1"),"GBK"); String mudidi= new String (request.getParameter("mudidi").getBytes("ISO-8859-1"),"GBK"); qishi=request.getParameter("qishidi"); mudi=request.getParameter("mudidi"); out.print(qishidi); out.print(mudidi); find.setQishi(qishi); find.setMudi(mudi); if(qishi!=null&&!qishi.equals("")&&mudi!=null&&!mudi.equals("")) { find.setKind; ResultSet rs=find.execute(); if(rs.next ()) out.print(rs.getString(1)); } %> </form> <%@ include file="tail.jsp"%> 我的BEAN 如下 package chaxun; import util.data; import java.sql.*; public class find { private int kind; data sqlbean=new data(); String sql; String checi; String qishi; String mudi; public find(){ kind=0; sql=""; } public void setKind(int k){ kind=k; } public int getKind(){ return kind; } public void setCheci(String che){ checi=che; } public String getCheci(){ return checi; } public void setQishi(String qi){ qishi=qi; } public String getQishi(){ return qishi; } public void setMudi(String mu){ mudi=mu; } public String getMudi(){ return mudi; } public String getSql(){ int m=getKind(); qishi=getQishi(); mudi=getMudi(); checi=getCheci(); switch { case 1:sql="select * from jibenbiao where checi='"+checi+ "'"; break; case 2:sql="select xiangxi1.checi from xiangxi1,xiangxi2 where xiangxi1.zhanming='"+qishi +"' and xiangxi2.zhanming='"+mudi+"'and xiangxi1.checi=xiangxi2.checi"; break; } return sql; } public ResultSet execute(){ ResultSet rs=sqlbean.executeQuery(getSql()); return rs; } public static void main(String []args){ } |
2.Re:java.lang.NullPointerException怎么解决 [Re: liujing319] | Copy to clipboard |
Posted by: chengbd Posted on: 2005-09-07 00:19 遇到这问题,实在“看”不出来,就“动手”一步步跟踪调试 |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |