<%@ page language="java" import="java.sql.*"%>
<%@ page contentType="text/html;charset=gb2312"%>
<html>
<head>
<title>汇总金额</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"></head>
<body bgcolor="#00CC99">
<div align="center">
<p><strong><font color="#FFCC66" size="6" face="华文行楷">办公自动化系统</font></strong></p>
<hr>
<center>
<font color="#0099FF" size="4" face="幼圆"><strong>请填写汇总详细情况</strong></font>
<form action="summoney_2.jsp" method="post">
<p align="left">起始日期:
<input type="text" id="begin_time" name="begin_time">
<p align="left">截止日期:
<input type="text" id="end_time" name="end_time">
<p align="center">
<input type="submit" id="confirm" name="confirm" value="填好了">
<input type="reset" id="reinput" name="reinput" value="重写">
</form>
</center>
</body>
</html>
就是获得输入日期,yyyy-MM-dd格式
这是第二个页面:
<%@ page language="java" import="java.util.*"%>
<%@ page import="java.text.*"%>
<%@ page contentType="text/html;charset=gb2312"%>
<html>
<head>
<title>金额汇总</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"></head>
<body bgcolor="#00cc99">
<div align="center">
<p><strong><font color="#FFCC66" size="6" face="华文行楷">办公自动化系统</font></strong></p>
<hr>
<center>
<strong><font color="#3399FF" size="4" face="幼圆">经费申请表预览 </font></strong>
<P align="left">起始日期:<%=request.getParameter("begin_time")%>
<P align="left">截止日期:<%=request.getParameter("end_time")%>
<%
SimpleDateFormat formatter=new SimpleDateFormat("yyyy-MM-dd");
%>
<%
String begin_time=request.getParameter("begin_time");
String end_time=request.getParameter("end_time");
Date res_begin=formatter.parse(begin_time);
Date res_end=formatter.parse(end_time);
%>
<form action="summoney_3.jsp" method="post">
<P><input type="submit" id="confirm" name="confirm" value="确认">
<input type="button" id="back" name="back" value="返回" onclick="javascript:history.go(-1)">
</P>
</form>
</center>
</body>
</html>
在这个页面里,我先把页面1输入的日期赋给字符串begin_time和end_time,在强制转换为日期格式,因为在我第三个页面里,我查询数据库时要用到where sub_time>res_begin和sub_time<res_end,我的sub_time是smalldatetime格式的,但这个页面运行时总报错:
Error: 500
Location: /shichang/summoney_2.jsp
Internal Servlet Error:
javax.servlet.ServletException: Unparseable date: ""
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:460)
at shichang.summoney_2_19._jspService(summoney_2_19.java:100)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
at javax.servlet.http.HttpServlet.service(HttpServlet.java)
at org.apache.tomcat.facade.ServletHandler.doService(ServletHandler.java:574)
at org.apache.tomcat.core.Handler.invoke(Handler.java:322)
at org.apache.tomcat.core.Handler.service(Handler.java:235)
at org.apache.tomcat.facade.ServletHandler.service(ServletHandler.java:485)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:917)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:833)
at org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Http10Interceptor.java:176)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:494)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:516)
at java.lang.Thread.run(Thread.java:536)
Root cause:
java.text.ParseException: Unparseable date: ""
at java.text.DateFormat.parse(DateFormat.java:334)
at shichang.summoney_2_19._jspService(summoney_2_19.java:90)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
at javax.servlet.http.HttpServlet.service(HttpServlet.java)
at org.apache.tomcat.facade.ServletHandler.doService(ServletHandler.java:574)
at org.apache.tomcat.core.Handler.invoke(Handler.java:322)
at org.apache.tomcat.core.Handler.service(Handler.java:235)
at org.apache.tomcat.facade.ServletHandler.service(ServletHandler.java:485)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:917)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:833)
at org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Http10Interceptor.java:176)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:494)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:516)
at java.lang.Thread.run(Thread.java:536)
这是第三个页面源代码:
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page language="java" import="java.util.*"%>
<%@ page import="java.sql.*"%>
<html>
<head>
<title>汇总金额</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"></head>
<body bgcolor="#00cc99">
<div align="center">
<p><strong><font color="#FFCC66" size="6" face="华文行楷">办公自动化系统</font></strong></p>
<p><hr>
<form action="summoney_4.jsp" method="post">
<jsp:useBean id="sum" scope="page" class="SQLServer.SQLServer_dbconnect"/>
<%
ResultSet rs;
rs=sum.executeQuery("select * from produce where sub_time>res_begin and sub_time<res_end");
while(rs.next())
{
%>
<P align=left>客户名:<%=rs.getString("custom_name")%>
<P align=left>产品名:<%=rs.getString("goods_name")%>
<P align=left>产品数量:<%=rs.getString("goods_amount")%>
<P align=left>订单金额:<%=rs.getString("sum_money")%>
<P align=left>交货日期:<%=rs.getString("sub_time")%>
<P align=left>下达日期:<%=rs.getString("now")%>
<hr>
<P align=center>
<input type="submit" id="confirm" name="confirm" value="查看总销售额">
<form action="summoney_2.jsp" method="post">
<input type="submit" name="back" value="返回">
<%}%>
<hr>
</form>
</P>
</body>
</html>
哪位前辈能帮忙解决,谢谢了!
4 个解决方案
#1
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
java.util.Date date1 = format.parse("2003-05-15");
#2
不行呀,还时有这样的错误:
Location: /shichang/summoney_2.jsp
Internal Servlet Error:
javax.servlet.ServletException: Unparseable date: ""
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:460)
at shichang.summoney_2_3._jspService(summoney_2_3.java:101)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
at javax.servlet.http.HttpServlet.service(HttpServlet.java)
at org.apache.tomcat.facade.ServletHandler.doService(ServletHandler.java:574)
at org.apache.tomcat.core.Handler.invoke(Handler.java:322)
at org.apache.tomcat.core.Handler.service(Handler.java:235)
at org.apache.tomcat.facade.ServletHandler.service(ServletHandler.java:485)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:917)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:833)
at org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Http10Interceptor.java:176)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:494)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:516)
at java.lang.Thread.run(Thread.java:536)
Root cause:
java.text.ParseException: Unparseable date: ""
at java.text.DateFormat.parse(DateFormat.java:334)
at shichang.summoney_2_3._jspService(summoney_2_3.java:91)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
at javax.servlet.http.HttpServlet.service(HttpServlet.java)
at org.apache.tomcat.facade.ServletHandler.doService(ServletHandler.java:574)
at org.apache.tomcat.core.Handler.invoke(Handler.java:322)
at org.apache.tomcat.core.Handler.service(Handler.java:235)
at org.apache.tomcat.facade.ServletHandler.service(ServletHandler.java:485)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:917)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:833)
at org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Http10Interceptor.java:176)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:494)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:516)
at java.lang.Thread.run(Thread.java:536)
Location: /shichang/summoney_2.jsp
Internal Servlet Error:
javax.servlet.ServletException: Unparseable date: ""
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:460)
at shichang.summoney_2_3._jspService(summoney_2_3.java:101)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
at javax.servlet.http.HttpServlet.service(HttpServlet.java)
at org.apache.tomcat.facade.ServletHandler.doService(ServletHandler.java:574)
at org.apache.tomcat.core.Handler.invoke(Handler.java:322)
at org.apache.tomcat.core.Handler.service(Handler.java:235)
at org.apache.tomcat.facade.ServletHandler.service(ServletHandler.java:485)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:917)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:833)
at org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Http10Interceptor.java:176)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:494)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:516)
at java.lang.Thread.run(Thread.java:536)
Root cause:
java.text.ParseException: Unparseable date: ""
at java.text.DateFormat.parse(DateFormat.java:334)
at shichang.summoney_2_3._jspService(summoney_2_3.java:91)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
at javax.servlet.http.HttpServlet.service(HttpServlet.java)
at org.apache.tomcat.facade.ServletHandler.doService(ServletHandler.java:574)
at org.apache.tomcat.core.Handler.invoke(Handler.java:322)
at org.apache.tomcat.core.Handler.service(Handler.java:235)
at org.apache.tomcat.facade.ServletHandler.service(ServletHandler.java:485)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:917)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:833)
at org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Http10Interceptor.java:176)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:494)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:516)
at java.lang.Thread.run(Thread.java:536)
#3
能用其他方法来实现我要求的这种查询吗?
#4
我放弃了!我换一种方法了
#1
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
java.util.Date date1 = format.parse("2003-05-15");
#2
不行呀,还时有这样的错误:
Location: /shichang/summoney_2.jsp
Internal Servlet Error:
javax.servlet.ServletException: Unparseable date: ""
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:460)
at shichang.summoney_2_3._jspService(summoney_2_3.java:101)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
at javax.servlet.http.HttpServlet.service(HttpServlet.java)
at org.apache.tomcat.facade.ServletHandler.doService(ServletHandler.java:574)
at org.apache.tomcat.core.Handler.invoke(Handler.java:322)
at org.apache.tomcat.core.Handler.service(Handler.java:235)
at org.apache.tomcat.facade.ServletHandler.service(ServletHandler.java:485)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:917)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:833)
at org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Http10Interceptor.java:176)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:494)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:516)
at java.lang.Thread.run(Thread.java:536)
Root cause:
java.text.ParseException: Unparseable date: ""
at java.text.DateFormat.parse(DateFormat.java:334)
at shichang.summoney_2_3._jspService(summoney_2_3.java:91)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
at javax.servlet.http.HttpServlet.service(HttpServlet.java)
at org.apache.tomcat.facade.ServletHandler.doService(ServletHandler.java:574)
at org.apache.tomcat.core.Handler.invoke(Handler.java:322)
at org.apache.tomcat.core.Handler.service(Handler.java:235)
at org.apache.tomcat.facade.ServletHandler.service(ServletHandler.java:485)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:917)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:833)
at org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Http10Interceptor.java:176)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:494)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:516)
at java.lang.Thread.run(Thread.java:536)
Location: /shichang/summoney_2.jsp
Internal Servlet Error:
javax.servlet.ServletException: Unparseable date: ""
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:460)
at shichang.summoney_2_3._jspService(summoney_2_3.java:101)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
at javax.servlet.http.HttpServlet.service(HttpServlet.java)
at org.apache.tomcat.facade.ServletHandler.doService(ServletHandler.java:574)
at org.apache.tomcat.core.Handler.invoke(Handler.java:322)
at org.apache.tomcat.core.Handler.service(Handler.java:235)
at org.apache.tomcat.facade.ServletHandler.service(ServletHandler.java:485)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:917)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:833)
at org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Http10Interceptor.java:176)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:494)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:516)
at java.lang.Thread.run(Thread.java:536)
Root cause:
java.text.ParseException: Unparseable date: ""
at java.text.DateFormat.parse(DateFormat.java:334)
at shichang.summoney_2_3._jspService(summoney_2_3.java:91)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
at javax.servlet.http.HttpServlet.service(HttpServlet.java)
at org.apache.tomcat.facade.ServletHandler.doService(ServletHandler.java:574)
at org.apache.tomcat.core.Handler.invoke(Handler.java:322)
at org.apache.tomcat.core.Handler.service(Handler.java:235)
at org.apache.tomcat.facade.ServletHandler.service(ServletHandler.java:485)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:917)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:833)
at org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Http10Interceptor.java:176)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:494)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:516)
at java.lang.Thread.run(Thread.java:536)
#3
能用其他方法来实现我要求的这种查询吗?
#4
我放弃了!我换一种方法了