根据课程号删除课程的时候,课程号(currId)报空指针错误,而且在action中打印也是为null;
这里是action内容://删除所选课程
public String deleteSelected()throws Exception{
//显示该生的学籍信息
HttpServletRequest request=ServletActionContext.getRequest();
String stuId=request.getSession().getAttribute("stuId").toString();
System.out.print("删除所选课程:");
System.out.print(stuId);
String kcurrId=request.getParameter("currId");
System.out.print(kcurrId);
ResultSet sqlSelect=Dbcon.executeQuery("select * from xuanke,linshic,bascurri,teacher where xuanke.kcurrId=bascurri.currId " +
" and linshic.xcurrId=bascurri.currId and linshic.xteaId=teacher.teaId " +
"and stuId=(select stuId from student where stuId='"+stuId+"')");
try{
if(sqlSelect.next())
{
ResultSet sqlSelect1=Dbcon.executeQuery("delete from xuanke where kcurrId='"+kcurrId+"' and stuId='"+stuId+"'"); sqlSelect.close();
sqlSelect1.close();
}
}
catch(Exception e){
e.printStackTrace();
}
return SUCCESS;
}
这里是页面内容:
<tr>
<td width="94" height="32">课程ID号</td>
<td width="204">课程名称</td>
<td width="95">授课教师</td>
<td width="64">上课时间</td>
<td width="90">课程类型</td>
<td width="54">退课 </td>
</tr>
<s:iterator value="scurrList">
<tr>
<td height="30"><s:property value="currId"/></td>
<td><s:property value="currName"/></td>
<td><s:property value="teaName"/></td>
<td>t</td>
<td><s:property value="xType"/></td>
<td><a href="deleteSelected.action?id=<s:property value="#session.stuId"/> & currId=<s:property value="currId"/>">退课</a> </td>
</tr>
</s:iterator>
这里是action内容://删除所选课程
public String deleteSelected()throws Exception{
//显示该生的学籍信息
HttpServletRequest request=ServletActionContext.getRequest();
String stuId=request.getSession().getAttribute("stuId").toString();
System.out.print("删除所选课程:");
System.out.print(stuId);
String kcurrId=request.getParameter("currId");
System.out.print(kcurrId);
ResultSet sqlSelect=Dbcon.executeQuery("select * from xuanke,linshic,bascurri,teacher where xuanke.kcurrId=bascurri.currId " +
" and linshic.xcurrId=bascurri.currId and linshic.xteaId=teacher.teaId " +
"and stuId=(select stuId from student where stuId='"+stuId+"')");
try{
if(sqlSelect.next())
{
ResultSet sqlSelect1=Dbcon.executeQuery("delete from xuanke where kcurrId='"+kcurrId+"' and stuId='"+stuId+"'"); sqlSelect.close();
sqlSelect1.close();
}
}
catch(Exception e){
e.printStackTrace();
}
return SUCCESS;
}
这里是页面内容:
<tr>
<td width="94" height="32">课程ID号</td>
<td width="204">课程名称</td>
<td width="95">授课教师</td>
<td width="64">上课时间</td>
<td width="90">课程类型</td>
<td width="54">退课 </td>
</tr>
<s:iterator value="scurrList">
<tr>
<td height="30"><s:property value="currId"/></td>
<td><s:property value="currName"/></td>
<td><s:property value="teaName"/></td>
<td>t</td>
<td><s:property value="xType"/></td>
<td><a href="deleteSelected.action?id=<s:property value="#session.stuId"/> & currId=<s:property value="currId"/>">退课</a> </td>
</tr>
</s:iterator>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货