<%MysqlDB db = Config.inst().db; %>
<form method="post">
<p> 查询日期:<input type="text" name="created_st" value="yyyy-mm-dd">到
<input type="text" name="created_et" value="yyyy-mm-dd">
<input type="submit" value="查询"></p>
</form>
<table border=1 width=400 class=data>
<tr><th>ID</th><th>姓名</th><th>充值总额(元)</th><th>充值前总额(元)</th><th>充值后总额(元)</th><th>日期</th></tr>
<tr>
<% String starttime = request.getParameter("created_st");
String endtime = request.getParameter("created_et");
ResultSet rs = db.query ("SELECT * FROM payments WHERE creat_at>'starttime' and creat_at<'endtime' ORDER BY creat_at");
while(rs.next()){
%>
<tr>
<td><%=rs.getString(1)%></td>
<td><%=rs.getString(2)%></td>
<td><%=rs.getString(3)%></td>
<td><%=rs.getString(4)%></td>
<td><%=rs.getString(5)%></td>
</tr>
<%
}
%>
</table>
org.apache.jasper.JasperException: An exception occurred processing JSP page /admin/payments.jsp at line 24
21: <% String starttime = request.getParameter("created_st");
22: String endtime = request.getParameter("created_et");
23: ResultSet rs = db.query ("SELECT * FROM payments WHERE creat_at>'starttime' and creat_at<'endtime' ORDER BY creat_at");
24: while(rs.next()){
25: %>
26: <tr>
27: <td><%=rs.getString(1)%></td>
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:568)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:470)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
root cause
java.lang.NullPointerException
org.apache.jsp.admin.payments_jsp._jspService(payments_jsp.java:140)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
------解决方案--------------------
ResultSet rs = db.query ("SELECT * FROM payments WHERE creat_at>'"+ starttime + "' and creat_at<'"+ endtime + "' ORDER BY creat_at");
ResultSet中的SQL应该是上面的样子吧 ?
加以判断来控制空指针 :--->
if (rs != null){
while(rs.next()){
...
}
}
代码迷推荐解决方案:An exception occurred processing JSP page,http://www.daimami.com/search?q=33144