日期:2014-05-17  浏览次数:20663 次

数据库错误……
<%
HttpSession ss=request.getSession();
String username=(String)ss.getAttribute("ppp");
%>
<%
if(username==""||username==null){
response.sendRedirect("/HW/Thingshow.jsp?bt=0");
}
%>
<%
String mon=request.getParameter("mon");
String mid=request.getParameter("mid");
String num=request.getParameter("num");
int Num=Integer.parseInt(num)-1;
%>
<%
  Connection conn=DB.getConn();
  Statement st=DB.getStatement(conn);
  String Mon="0";
  String sql="select money from user where username='"+username+"'";
  ResultSet rs=DB.executeQuery(st,sql);
  if(rs.next()){
  Mon=rs.getString(1);
  }
  rs.close();
%>
<%
  if(mon.compareTo(Mon)>0){
  response.sendRedirect("/HW/Thingshow.jsp?ok=1");
  }
 %>
为什么
只要加上<%
if(username==""||username==null){
response.sendRedirect("/HW/Thingshow.jsp?bt=0");
}
%>
就会有这样的错误……

java.lang.IllegalStateException

org.apache.jasper.JasperException: An exception occurred processing JSP page /Shop_ok.jsp at line 35

32: %>
33: <%
34: if(mon.compareTo(Mon)>0){
35: response.sendRedirect("/HW/Thingshow.jsp?ok=1");
36: }
37: %>


------解决方案--------------------
刚刚的给你的方法不对,嘿嘿,我找到原因了,是因为你用了两次response.sendRedirect()方法,该方法一个请求只能相应一次,如果第一次判断username是true的话,调用后response.sendRedirect()已经请求响应给client端了,不能进行第二次响应,一次请求<-->一次响应
------解决方案--------------------
response.sendRedirect("/HW/Thingshow.jsp?bt=0");方法后加return;语句
我的异常网推荐解决方案:An exception occurred processing JSP page,http://www.aiyiweb.com/j2se/33144.html