空指针错误,比如你在condiction.equals(cond1)前没有判断cnodiction是否为null,还有在while(!result.isAfterLast())前也要做是否为null的判断
解决方案 »
- 怎么访问WEB—INF下的文件
- ireport中detail自适应高度,如何定高打印横线
- 如何在jsp中写一个tree
- 有关Servlet设计初始方法问题,只想要一下思路!
- 一个背景问题
- 框架页中,子框架页把表单提交给父框架页处理,如何实现?
- 在Java中trim()函数的返回值
- ▲▲▲高分求解: 谁用过 JRTF1.1 处理 Word, 中文乱码问题请教!
- 关于jbuilder中数据库连接的问题!!!!!!!!!!!!!!!!!!!!!!!!
- http://test.jsp?menu_parent=国际新闻 为什么我在test.jsp中用以下代码显示却是乱码?
- 问一个TOMCAT服务器的问题
- 请教JSP+javaBean连接数据库时。。。。的程序出错原因
可能出在:
String condiction=request.getParameter("condiction");
String Qvalue=request.getParameter("value");
仔细检查参数名称condiction,value是否正确!建议用return断点检查!
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page language="java"%><%@ page import="QueryBean"%>
<jsp:useBean id="QueryBean" class="QueryBean" scope="session"/>
<jsp:setProperty name="QueryBean" property="*"/><%@ page import="java.io.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.util.Date"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.net.*"%><%
String cond1="课程名称";
String cond2="课程编号";
String condiction=request.getParameter("condiction");
String Qvalue=request.getParameter("value");
String sql="select * from T_jxTeachScheme where ";
if (condiction==null && Qvalue==null)
{
sql=null;
}
else
{
condiction=condiction.trim();
Qvalue=Qvalue.trim();
if (condiction.equals(cond1))
{
sql+=" fCName_China like '"+Qvalue+"' ";
}
else if (condiction.equals(cond2))
{
sql+=" fCourse_Num like '"+Qvalue+"' ";
}
}
ResultSet result=null;
if (sql!=null)
{
result=QueryBean.Query(sql);
}
%><html>
<head>
<title>课程查询系统</title>
</head>
<body bgcolor="#3399ff">
<center>
<font face="华文行楷" color="#00ffff" size="+6">课程查询系统</font>
<hr size="3" color="#ffffff">
<form action="Course.jsp" method="post">
<table width="80%">
<tr>
<td width="80%">
<font face="华文行楷" color="#ff0000">查询条件一:</font>
<select name="condiction">
<option> </option>
<option>课程名称</option>
<option>课程编号</option>
</select>
<font face="华文行楷" color="#ff0000">查询内容:</font>
<input type="Text" name="value">
</td>
<td width="20%"><input type="Submit" value="查询"></td>
</tr>
</table>
</form>
<hr size="3" color="#ffffff">
<font face="华文行楷" color="#ffffff" size="+3">查询结果如下表:</font>
<table border="1" cellspacing="2" cellpadding="2" width="80%">
<tr bgcolor="#00ffff">
<td width="30%"><center><font face="华文行楷" size="+2" color="#ff0000">课程编号</font></center></td>
<td width="70%"><center><font face="华文行楷" size="+2" color="#ff0000">课程名称</font></center></td>
</tr>
<%
if (result!=null)
{
while(!result.isAfterLast())
{
%>
<tr>
<td width="30%"><center><%=result.getString("fCourse_Num")%></center></td>
<td width="70%"><center><%=result.getString("fCName_China")%></center></td>
</tr>
<%
result.next();
}
result.close();
}
%>
</table>
</center>
<hr size="3" color="#ffffff">
<%@ include file="FootIndex.jsp"%>
</body>
</html>