myeclipse 6.01+jsp+tomcat6.0+servlt中jsp跳转调用servlet空指针错误,不知道哪里错误,求助阿!!! 跟踪调试 看下WORK下的Class 309行 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 在309行加入断点,在myeclipse以debug方式启动tomcat,调试一下 <%@ page contentType="text/html; charset=gb2312" errorPage="" %><%@ page import="java.io.*, java.util.*,java.lang.*,java.sql.*,foundation.da.*, foundation.util.TranCode, foundation.util.Debug, dev.comm.WarehouseInfoBean" %><% request.setCharacterEncoding("GBK"); WarehouseInfoBean bean=(WarehouseInfoBean)request.getAttribute("CommonBean");//创建Bean对象 String pages="",rowCounts="",pageNums=""; if(bean!=null){ String Msg=bean.getErrorMsg("提示信息"); if(Msg!=null){ String javascript="<script language='JavaScript' type='text/javascript'> alert('提示信息:"+Msg+"') </script>"; out.print(javascript) ; request.removeAttribute("提示信息"); } pages=bean.getPageCounts(); //满足条件的总页数 rowCounts = bean.getRowCounts();//满足条件的总记录数 pageNums = bean.getPageNum();//当前页页码 }%><jsp:useBean id="CommonBean" scope="request" class="dev.comm.WarehouseInfoBean"/> <jsp:setProperty name="CommonBean" property="*" /><%if (CommonBean.isSubmit(request)){ System.out.println("================in Warehouselist is submit"); CommonBean.tranCode();%><jsp:forward page="/CommonForm"/><%}%><html><head><title>设备管理系统</title><script language="JavaScript" src="javascripts/telecompublic.js" type="text/javascript"></script><script language="JavaScript" src="javascripts/content.js" type="text/javascript"></script><link rel="stylesheet" href="index.css" /><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><meta http-equiv= "Refresh " content= "1 " url= "" /> <style type="text/css">#Layer1 { position:absolute; width:930px; height:330px; z-index:1; left: 10px; top: 215px;}#Layer2 { position:absolute; width:971px; height:45px; z-index:1; top: 170px; left: -5px;}body {background-image: url(images/bg-2.jpg);}</style><script language="JavaScript"> var lineValue=""; var oldObj = null; function switchItem1(KEY){ if(oldObj != null){ oldObj.className = "noClick" } newObj = event.srcElement.parentElement; newObj.className = "clicked" oldObj = newObj lineValue=KEY; var len = document.form1.elements.length; for(i=0;i<len;i++){ if((document.form1.elements[i].type=="checkbox")&&(document.form1.elements[i].value==KEY)){ if(document.form1.elements[i].checked == false){ document.form1.elements[i].checked = true; }else{ document.form1.elements[i].checked = false; } } } window.location="./CommonForm?beanName=dev.comm.WarehouseInfoBean&jspURL=DetailWareInfoPage.jsp&t_Ckbh="+KEY+"&detailFlag=true"; } function orderInfos(KEY){ document.form1.orderField.value=KEY; if(document.form1.orderType.value==null||document.form1.orderType.value==""||document.form1.orderType.value=="DESC"){ document.form1.orderType.value="ASC"; }else{ document.form1.orderType.value="DESC"; } document.form1.PubSubmit.name="bfmd_page"; document.form1.PubSubmit.click(); } function goPreviousPage(){ var tempPageNum = document.form1.pageNum.value; var maxPage = document.form1.pageCounts.value; if(tempPageNum>1){ document.form1.pageNum.value=tempPageNum-1; document.form1.PubSubmit.name="bfmd_page"; document.form1.PubSubmit.click(); } } function goNextPage(){ var tempPageNum = document.form1.pageNum.value; var maxPage = document.form1.pageCounts.value; if((tempPageNum-0)<(maxPage-0)){ document.form1.pageNum.value=tempPageNum-(-1); document.form1.PubSubmit.name="bfmd_page"; document.form1.PubSubmit.click(); } } function loadSearch(){ document.form1.PubSubmit.name="bfmd_search"; document.form1.PubSubmit.click(); } function checkData(){ alert('is submit'); } function initLineValue(KEY){ if (lineValue==null||lineValue==""){ lineValue=KEY; } }</script> <%/*** 用于点击菜单项时清空会话中的条件字符串数据*/ String setFlag = request.getParameter("setFlag"); if(setFlag!=null&&(setFlag.equals("T"))){ request.getSession().removeAttribute("whereSQL"); //request.getSession().removeAttribute("defCondition"); request.setAttribute("setFlag","F");}%></head> <body leftmargin="0" topmargin="images/0.jpg" MS_POSITIONING="GridLayout"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0"><TBODY><tr><td height="20" background="images/top_2.jpg"><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0"><tr><td width="7%"><img src="images/top_1.jpg" width="70" height="20"></td><td width="79%"> </td><td width="14%"><img src="images/top_3.jpg" width="68" height="20"></td></tr></table></td></tr><tr><td height="79" background="images/bg-3.jpg"><table width="100%" height="79" border="0" cellpadding="0" cellspacing="0"><tr><td><div align="center"><img src="images/top_left1.jpg" width="386" height="89" align="absmiddle" /></div></td><td align="right" valign="middle"><img src="images/top_6.jpg" width="207" height="89" /></td></tr></table></td></tr><tr><td height="30" bgcolor="#e3ebf5"><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#00CCFF"><tr><td width="4%" align="center"><img src="iamges/0.jpg" width="17" height="16" /></td><td width="32%" height="25" align="center"><div align="left" class="STYLE1"><font color=blue size=3 face="隶书"><% Timestamp time = new Timestamp(System.currentTimeMillis()); out.println(time.toString()); %></font></div></td><td width="41%" align="center" class="f12"><div align="center"><marquee direction="left" class="STYLE1" ><font color=blue size=3 face="隶书">您好!欢迎使用设备管理信息系统 </font></marquee></div></td><td width="10%" align="left"><div align="center" class="STYLE1"><div align="right"><a href="login0.jsp"><font color=blue size=3 face="隶书">退出系统</font></a></div></div></td><td width="1%" align="left"> </td><td width="12%" align="left"><div align="center" class="STYLE1"><font color=blue size=3 face="隶书"><a href="index.jsp">首页</a></font></div></td></tr></table></td></tr></TBODY></table><div id="Layer2"> <div align="center" class="STYLE1"> <td width="2" height="2" colspan="1" rowspan="1" align="center" valign="baseline" nowrap="nowrap" bgcolor="#0099FF" scope="col"> <table width="200" border="0"> <tr> <td><a href="systemManagement.jsp" target="_top" onclick="MM_nbGroup('down','group1','xtgl','',1)" onmouseover="MM_nbGroup('over','xtgl','','',1)" onmouseout="MM_nbGroup('out')"><img src="images/xtgl.jpg" alt="用户和权限修改" name="xtgl" width="140" height="25" border="0" id="xtgl" /></a></td> <td> </td> <td><a href="caigoumanagement.jsp" target="_top" onclick="MM_nbGroup('down','group1','cggl','',1)" onmouseover="MM_nbGroup('over','cggl','','',1)" onmouseout="MM_nbGroup('out')"><img src="images/cggl.jpg" alt="设备的采购信息情况" name="cggl" width="140" height="25" border="0" id="cggl" /></a></td> <td> </td> <td><a href="taizhangmanagement.jsp" target="_top" onclick="MM_nbGroup('down','group1','sbtzgl','',1)" onmouseover="MM_nbGroup('over','sbtzgl','','',1)" onmouseout="MM_nbGroup('out')"><img src="images/sbtzgl.jpg" alt="设备的明细台帐详情" name="sbtzgl" width="140" height="25" border="0" id="sbtzgl"/></a></td> <td> </td> <td><a href="shebeiyunxing.jsp" target="_top" onclick="MM_nbGroup('down','group1','sbyxgl','',1)" onmouseover="MM_nbGroup('over','sbyxgl','','',1)" onmouseout="MM_nbGroup('out')"><img src="images/sbyxgl.jpg" alt="现在运行设备的详细情况" name="sbyxgl" width="140" height="25" border="0" id="sbyxgl" /></a></td> <td> </td> <td><a href="shebeiweihu.jsp" target="_top" onclick="MM_nbGroup('down','group1','sbwhgl','',1)" onmouseover="MM_nbGroup('over','sbwhgl','','',1)" onmouseout="MM_nbGroup('out')"><img src="images/sbwhgl.jpg" alt="设备维护情况" name="sbwhgl" width="140" height="25" border="0" id="sbwhgl" /></a></td> <td> </td> <td><a href="ListWarehouseInfoPage.jsp" target="_top" onclick="MM_nbGroup('down','group1','ckgl','',1)" onmouseover="MM_nbGroup('over','ckgl','','',1)" onmouseout="MM_nbGroup('out')"><img src="images/ckgl.jpg" alt="仓库的详细情况" name="ckgl" width="140" height="25" border="0" id="ckgl" /></a></td> </tr> </table> </td> </div></div><div id="Layer1"><form name="form1" method="post" action="./ListWarehouseInfoPage.jsp" onSubmit="return checkData()"> <input type="hidden" name="orderField" value="CommonBean.getOrderField()"> <input type="hidden" name="orderType" value="CommonBean.getOrderType()"> <input type="hidden" name="pageNum" value="pageNums"> <input type="hidden" name="pageCounts" value="pages"> <input type="hidden" name="rowCounts" value="rowCounts"> <center> <tr> <td colspan="7"><font color="blue" size="5" face="隶书">仓库信息维护</font></td> </tr> </center> <tr><td> </td></tr> <tr><td colspan="7"> </td></tr><table width="700" border="1" align="center" class="STYLE1"> <tr> <th width="5%">选择</th> <th style="cursor:hand" title="单击这里,按仓库编号排序" onClick="orderInfos('t_Ckbh')">仓库编号</th> <th style="cursor:hand" title="单击这里,按设备类别排序" onClick="orderInfos('t_Rkcplb')">入库产品类别</th> <th style="cursor:hand" title="单击这里,按设备名称排序" onClick="orderInfos('t_Rkcpmc')">入库产品名称</th> <th style="cursor:hand" title="单击这里,按入库日期排序" onClick="orderInfos('t_Rkrq')">入库日期</th> <th style="cursor:hand" title="单击这里,按现有数量排序" onClick="orderInfos('t_Xysl')">现有数量</th> </tr> <% DbResultSet dbrs = bean.getDbrs(); int i=1; String tmpState="",stateName="",firstRowKey=""; if(dbrs!=null&&dbrs.size()>0){ while(dbrs.next()){ tmpState = dbrs.getString(19); if(tmpState!=null && tmpState.equals("T")){ stateName="正常"; }else{ stateName="缺货"; } if(i==1){ firstRowKey = dbrs.getString(1); %> <script language="JavaScript"> initLineValue("<%=firstRowKey%>"); </script> <tr class="clicked" id="<%=dbrs.getString(1)%>" onClick="switchItem1(id);" onMouseOver="this.className='clicked'" onMouseOut="this.className='noClick'"> <td nowrap height="16" align="center"><input type="checkbox" name="checkbox<%=i+1%>" value="<%=firstRowKey%>"></td> <td><%=dbrs.getString(6)%></td> <td><%=dbrs.getString(11)%></td> <td><%=dbrs.getString(10)%></td> <td><%=dbrs.getString(16)%></td> </tr> <%} else{%> <tr class="noClick" id="<%=dbrs.getString(1)%>" onClick="switchItem1(id);" onMouseOver="this.className='clicked'" onMouseOut="this.className='noClick'"> <td nowrap height="16" align="center"><input type="checkbox" name="checkbox<%=i+1%>" value="<%=firstRowKey%>"></td> <td><%=dbrs.getString(6)%></td> <td><%=dbrs.getString(11)%></td> <td><%=dbrs.getString(10)%></td> <td><%=dbrs.getString(16)%></td> </tr> <%} i++; } }%></table> <tr> <td> </td></tr><table width="700" border="1" align="center" class="STYLE1"> <tr align="center" class="STYLE1"> <td> <input name="jspURL" type="hidden" value="./ListWarehouseInfoPage.jsp"> <input name="checkAll" type="button" class="button1" id="checkAll" value="全选" onClick="checkAll_top()"> <input name="delete" type="button" class="button1" id="delete" value="删除选中" onClick="confirmDelete()"> <input name="add" type="button" class="button1" id="add" value="新增设备" onClick="confirmDelete()"> <input name="chang" type="button" class="button1" id="chang" value="修改选中" onClick="confirmDelete()"> <input name="chang" type="button" class="button1" id="chang" value="查看选中" onClick="confirmDelete()"> <input name="PubSubmit" type=Submit class="v_button" value="1"> </td> </tr> <%int tempNum=0; if(CommonBean.getPageNum()==null||CommonBean.getPageNum().equals("")){ tempNum=1; }else{ tempNum = Integer.parseInt(CommonBean.getPageNum()); } if(tempNum>1){ %> <tr align="center"> <td> <input name="bfmd_previous" type="button" class="button1" id="previousPage" value="上一页" onClick="goPreviousPage()"> <% } if(tempNum<Long.parseLong(pages)){ %> <input name="bfmd_next" type="button" class="button1" id="nextPage" value="下一页" onClick="goNextPage()"> </td> </tr> <%} out.println("总页数:"+ pages); out.println("当前页:"+pageNums); out.println("当前符合查询条件的记录数:" + rowCounts); %> </table></form></div></body></html> Jsp中servlet的空指针异常2008-11-16 15:30Jsp中servlet的空指针异常该异常对于初学者来说经常遇到,当一个对象的地址为空,用该对象调用方法时候会产生空指针异常;例如:<% Object str1 = request.getSession().getAttribute("name"); if (str1 != null) {//一定要判断该对象是不是为空,空指针异常往往在这里出现 //当一个对象是空时候如果调用该对象的方法则报空指针异常; out.println(str1.toString()); } else { } %>当一个对象调用其方法,返回另一个对象的属性值的时候,诺另一个对象地址为空时候,则会产生空指针异常,该异常很难被察觉,故程序员在编程过程中一定要仔细,下面的是一个很典型的例子: <% try{//空指针异常捕获,当第一次访问没有cookie,这个时候会报异常所以这里要捕获异常 //等cookie生成之后就没有异常了。 Cookie cookies[] = request.getCookies();//注意空指针异常, //当服务端没有设置cookie对象时候则报空指异常 if (cookies[0] != null) { if (cookies[0].getValue().equals("jiangnan")) { response.sendRedirect("welcome.jsp"); } } else { } }catch(NullPointerException e){ } %> struts 中如果从jsp向action中传对象集合,几天都找不到解决方法 请教一个FckEditor的问题 请问大家有没有碰过传 经过Servlet后变成 ? 问号的情况。 求web 数学公式 编辑器-开源或者免费的! 空指针错误,求高手赐教! 如何获得来访的服务器IP地址。 新手请求帮助 servlet中怎么包含一个JSP或HTML文件!! 如何在juilder7.0中添加tomcat4.1? 编译时程序提示出错? session获取不到验证码的问题(诚心诚意请教) JSP中类别问题
<%@ page import="java.io.*, java.util.*,java.lang.*,java.sql.*,foundation.da.*,
foundation.util.TranCode,
foundation.util.Debug,
dev.comm.WarehouseInfoBean" %>
<% request.setCharacterEncoding("GBK");
WarehouseInfoBean bean=(WarehouseInfoBean)request.getAttribute("CommonBean");//创建Bean对象
String pages="",rowCounts="",pageNums="";
if(bean!=null){
String Msg=bean.getErrorMsg("提示信息");
if(Msg!=null){
String javascript="<script language='JavaScript' type='text/javascript'> alert('提示信息:"+Msg+"') </script>";
out.print(javascript) ;
request.removeAttribute("提示信息");
}
pages=bean.getPageCounts(); //满足条件的总页数
rowCounts = bean.getRowCounts();//满足条件的总记录数
pageNums = bean.getPageNum();//当前页页码
}%>
<jsp:useBean id="CommonBean" scope="request" class="dev.comm.WarehouseInfoBean"/>
<jsp:setProperty name="CommonBean" property="*" />
<%if (CommonBean.isSubmit(request)){
System.out.println("================in Warehouselist is submit");
CommonBean.tranCode();
%>
<jsp:forward page="/CommonForm"/>
<%}%>
<html>
<head>
<title>设备管理系统</title>
<script language="JavaScript" src="javascripts/telecompublic.js" type="text/javascript"></script>
<script language="JavaScript" src="javascripts/content.js" type="text/javascript"></script>
<link rel="stylesheet" href="index.css" />
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta http-equiv= "Refresh " content= "1 " url= "" />
<style type="text/css">#Layer1 {
position:absolute;
width:930px;
height:330px;
z-index:1;
left: 10px;
top: 215px;
}
#Layer2 {
position:absolute;
width:971px;
height:45px;
z-index:1;
top: 170px;
left: -5px;
}
body {
background-image: url(images/bg-2.jpg);
}
</style>
<script language="JavaScript">
var lineValue="";
var oldObj = null;
function switchItem1(KEY){
if(oldObj != null){
oldObj.className = "noClick"
}
newObj = event.srcElement.parentElement;
newObj.className = "clicked"
oldObj = newObj
lineValue=KEY;
var len = document.form1.elements.length;
for(i=0;i<len;i++){
if((document.form1.elements[i].type=="checkbox")&&(document.form1.elements[i].value==KEY)){
if(document.form1.elements[i].checked == false){
document.form1.elements[i].checked = true;
}else{
document.form1.elements[i].checked = false;
}
}
}
window.location="./CommonForm?beanName=dev.comm.WarehouseInfoBean&jspURL=DetailWareInfoPage.jsp&t_Ckbh="+KEY+"&detailFlag=true";
}
function orderInfos(KEY){
document.form1.orderField.value=KEY;
if(document.form1.orderType.value==null||document.form1.orderType.value==""||document.form1.orderType.value=="DESC"){
document.form1.orderType.value="ASC";
}else{
document.form1.orderType.value="DESC";
}
document.form1.PubSubmit.name="bfmd_page";
document.form1.PubSubmit.click();
}
function goPreviousPage(){
var tempPageNum = document.form1.pageNum.value;
var maxPage = document.form1.pageCounts.value;
if(tempPageNum>1){
document.form1.pageNum.value=tempPageNum-1;
document.form1.PubSubmit.name="bfmd_page";
document.form1.PubSubmit.click();
}
}
function goNextPage(){
var tempPageNum = document.form1.pageNum.value;
var maxPage = document.form1.pageCounts.value;
if((tempPageNum-0)<(maxPage-0)){
document.form1.pageNum.value=tempPageNum-(-1);
document.form1.PubSubmit.name="bfmd_page";
document.form1.PubSubmit.click();
}
}
function loadSearch(){
document.form1.PubSubmit.name="bfmd_search";
document.form1.PubSubmit.click();
}
function checkData(){
alert('is submit');
}
function initLineValue(KEY){
if (lineValue==null||lineValue==""){
lineValue=KEY;
}
}
</script> <%
/**
* 用于点击菜单项时清空会话中的条件字符串数据
*/
String setFlag = request.getParameter("setFlag");
if(setFlag!=null&&(setFlag.equals("T"))){
request.getSession().removeAttribute("whereSQL");
//request.getSession().removeAttribute("defCondition");
request.setAttribute("setFlag","F");
}%>
</head>
<tr>
<td height="20" background="images/top_2.jpg"><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="7%"><img src="images/top_1.jpg" width="70" height="20"></td>
<td width="79%"> </td>
<td width="14%"><img src="images/top_3.jpg" width="68" height="20"></td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="79" background="images/bg-3.jpg"><table width="100%" height="79" border="0" cellpadding="0" cellspacing="0">
<tr><td><div align="center"><img src="images/top_left1.jpg" width="386" height="89" align="absmiddle" /></div></td><td align="right" valign="middle"><img src="images/top_6.jpg" width="207" height="89" /></td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="30" bgcolor="#e3ebf5"><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#00CCFF">
<tr>
<td width="4%" align="center"><img src="iamges/0.jpg" width="17" height="16" /></td>
<td width="32%" height="25" align="center"><div align="left" class="STYLE1">
<font color=blue size=3 face="隶书">
<% Timestamp time = new Timestamp(System.currentTimeMillis());
out.println(time.toString());
%></font></div></td>
<td width="41%" align="center" class="f12"><div align="center"><marquee direction="left" class="STYLE1" ><font color=blue size=3 face="隶书">您好!欢迎使用设备管理信息系统 </font></marquee></div></td>
<td width="10%" align="left"><div align="center" class="STYLE1">
<div align="right"><a href="login0.jsp"><font color=blue size=3 face="隶书">退出系统</font></a></div>
</div></td>
<td width="1%" align="left"> </td>
<td width="12%" align="left"><div align="center" class="STYLE1"><font color=blue size=3 face="隶书"><a href="index.jsp">首页</a></font></div></td>
</tr>
</table></td>
</tr></TBODY>
</table>
<div id="Layer2">
<div align="center" class="STYLE1">
<td width="2" height="2" colspan="1" rowspan="1" align="center" valign="baseline" nowrap="nowrap" bgcolor="#0099FF" scope="col">
<table width="200" border="0">
<tr>
<td><a href="systemManagement.jsp" target="_top" onclick="MM_nbGroup('down','group1','xtgl','',1)" onmouseover="MM_nbGroup('over','xtgl','','',1)" onmouseout="MM_nbGroup('out')"><img src="images/xtgl.jpg" alt="用户和权限修改" name="xtgl" width="140" height="25" border="0" id="xtgl" /></a></td>
<td> </td>
<td><a href="caigoumanagement.jsp" target="_top" onclick="MM_nbGroup('down','group1','cggl','',1)" onmouseover="MM_nbGroup('over','cggl','','',1)" onmouseout="MM_nbGroup('out')"><img src="images/cggl.jpg" alt="设备的采购信息情况" name="cggl" width="140" height="25" border="0" id="cggl" /></a></td>
<td> </td>
<td><a href="taizhangmanagement.jsp" target="_top" onclick="MM_nbGroup('down','group1','sbtzgl','',1)" onmouseover="MM_nbGroup('over','sbtzgl','','',1)" onmouseout="MM_nbGroup('out')"><img src="images/sbtzgl.jpg" alt="设备的明细台帐详情" name="sbtzgl" width="140" height="25" border="0" id="sbtzgl"/></a></td>
<td> </td>
<td><a href="shebeiyunxing.jsp" target="_top" onclick="MM_nbGroup('down','group1','sbyxgl','',1)" onmouseover="MM_nbGroup('over','sbyxgl','','',1)" onmouseout="MM_nbGroup('out')"><img src="images/sbyxgl.jpg" alt="现在运行设备的详细情况" name="sbyxgl" width="140" height="25" border="0" id="sbyxgl" /></a></td>
<td> </td>
<td><a href="shebeiweihu.jsp" target="_top" onclick="MM_nbGroup('down','group1','sbwhgl','',1)" onmouseover="MM_nbGroup('over','sbwhgl','','',1)" onmouseout="MM_nbGroup('out')"><img src="images/sbwhgl.jpg" alt="设备维护情况" name="sbwhgl" width="140" height="25" border="0" id="sbwhgl" /></a></td>
<td> </td>
<td><a href="ListWarehouseInfoPage.jsp" target="_top" onclick="MM_nbGroup('down','group1','ckgl','',1)" onmouseover="MM_nbGroup('over','ckgl','','',1)" onmouseout="MM_nbGroup('out')"><img src="images/ckgl.jpg" alt="仓库的详细情况" name="ckgl" width="140" height="25" border="0" id="ckgl" /></a></td>
</tr>
</table>
</td>
</div>
</div>
<div id="Layer1">
<form name="form1" method="post" action="./ListWarehouseInfoPage.jsp" onSubmit="return checkData()">
<input type="hidden" name="orderField" value="CommonBean.getOrderField()">
<input type="hidden" name="orderType" value="CommonBean.getOrderType()">
<input type="hidden" name="pageNum" value="pageNums">
<input type="hidden" name="pageCounts" value="pages">
<input type="hidden" name="rowCounts" value="rowCounts">
<center>
<tr>
<td colspan="7"><font color="blue" size="5" face="隶书">仓库信息维护</font></td>
</tr>
</center>
<tr><td> </td></tr>
<tr><td colspan="7"> </td></tr>
<table width="700" border="1" align="center" class="STYLE1">
<tr>
<th width="5%">选择</th>
<th style="cursor:hand" title="单击这里,按仓库编号排序" onClick="orderInfos('t_Ckbh')">仓库编号</th>
<th style="cursor:hand" title="单击这里,按设备类别排序" onClick="orderInfos('t_Rkcplb')">入库产品类别</th>
<th style="cursor:hand" title="单击这里,按设备名称排序" onClick="orderInfos('t_Rkcpmc')">入库产品名称</th>
<th style="cursor:hand" title="单击这里,按入库日期排序" onClick="orderInfos('t_Rkrq')">入库日期</th>
<th style="cursor:hand" title="单击这里,按现有数量排序" onClick="orderInfos('t_Xysl')">现有数量</th>
</tr>
<% DbResultSet dbrs = bean.getDbrs();
int i=1;
String tmpState="",stateName="",firstRowKey=""; if(dbrs!=null&&dbrs.size()>0){
while(dbrs.next()){
tmpState = dbrs.getString(19);
if(tmpState!=null && tmpState.equals("T")){
stateName="正常";
}else{
stateName="缺货";
}
if(i==1){
firstRowKey = dbrs.getString(1);
%>
<script language="JavaScript">
initLineValue("<%=firstRowKey%>");
</script>
<tr class="clicked" id="<%=dbrs.getString(1)%>" onClick="switchItem1(id);" onMouseOver="this.className='clicked'" onMouseOut="this.className='noClick'">
<td nowrap height="16" align="center"><input type="checkbox" name="checkbox<%=i+1%>" value="<%=firstRowKey%>"></td>
<td><%=dbrs.getString(6)%></td>
<td><%=dbrs.getString(11)%></td>
<td><%=dbrs.getString(10)%></td>
<td><%=dbrs.getString(16)%></td>
</tr>
<%}
else{%>
<tr class="noClick" id="<%=dbrs.getString(1)%>" onClick="switchItem1(id);" onMouseOver="this.className='clicked'" onMouseOut="this.className='noClick'">
<td nowrap height="16" align="center"><input type="checkbox" name="checkbox<%=i+1%>" value="<%=firstRowKey%>"></td>
<td><%=dbrs.getString(6)%></td>
<td><%=dbrs.getString(11)%></td>
<td><%=dbrs.getString(10)%></td>
<td><%=dbrs.getString(16)%></td>
</tr>
<%}
i++;
}
}%>
</table>
<td> </td>
</tr>
<table width="700" border="1" align="center" class="STYLE1">
<tr align="center" class="STYLE1">
<td>
<input name="jspURL" type="hidden" value="./ListWarehouseInfoPage.jsp">
<input name="checkAll" type="button" class="button1" id="checkAll" value="全选" onClick="checkAll_top()">
<input name="delete" type="button" class="button1" id="delete" value="删除选中" onClick="confirmDelete()">
<input name="add" type="button" class="button1" id="add" value="新增设备" onClick="confirmDelete()">
<input name="chang" type="button" class="button1" id="chang" value="修改选中" onClick="confirmDelete()">
<input name="chang" type="button" class="button1" id="chang" value="查看选中" onClick="confirmDelete()">
<input name="PubSubmit" type=Submit class="v_button" value="1">
</td>
</tr>
<%int tempNum=0;
if(CommonBean.getPageNum()==null||CommonBean.getPageNum().equals("")){
tempNum=1;
}else{
tempNum = Integer.parseInt(CommonBean.getPageNum());
}
if(tempNum>1){
%>
<tr align="center">
<td> <input name="bfmd_previous" type="button" class="button1" id="previousPage" value="上一页" onClick="goPreviousPage()">
<%
}
if(tempNum<Long.parseLong(pages)){
%>
<input name="bfmd_next" type="button" class="button1" id="nextPage" value="下一页" onClick="goNextPage()">
</td>
</tr>
<%}
out.println("总页数:"+ pages);
out.println("当前页:"+pageNums);
out.println("当前符合查询条件的记录数:" + rowCounts);
%>
</table>
</form>
</div>
</body>
</html>
当一个对象调用其方法,返回另一个对象的属性值的时候,诺另一个对象地址为空时候,则会产生空指针异常,该异常很难被察觉,故程序员在编程过程中一定要仔细,下面的是一个很典型的例子:
<% try{//空指针异常捕获,当第一次访问没有cookie,这个时候会报异常所以这里要捕获异常 //等cookie生成之后就没有异常了。 Cookie cookies[] = request.getCookies();//注意空指针异常, //当服务端没有设置cookie对象时候则报空指异常 if (cookies[0] != null) { if (cookies[0].getValue().equals("jiangnan")) { response.sendRedirect("welcome.jsp"); } } else { } }catch(NullPointerException e){ }
%>