提交之后页面不再跳转.而且页面也无任何提示信息
代码.一个很简单的程序
<%
String ID = request.getParameter( "ID ");
String password = request.getParameter( "password ");
String rpassword = request.getParameter( "rpassword ");
String name = request.getParameter( "name ");
String sex = request.getParameter( "sex ");
String year = request.getParameter( "year ");
if(year.length() ==1) year = "0 "+year;
String mouth = request.getParameter( "mouth ");
if(mouth.length() == 1) mouth = "0 "+mouth;
String day = request.getParameter( "day ");
if(day.length() == 1) day = "0 "+day;
String date = year+ "- "+mouth+ "- "+day;
String description = request.getParameter( "description ");
Connection con = null;
PreparedStatement psm = null;
ResultSet rs = null;
try
{
Class.forName( "com.mysql.jdbc.Driver ").newInstance();
String url = "jdbc:mysql://localhost/mydb ";
con = DriverManager.getConnection(url, "root ", "dolove ");
psm = con.preparedStatement( "insert into users values(?,?,?,?,?,?) ");
psm.setString(1,ID);
psm.setString(2,password);
psm.setString(3,name);
psm.setString(4,sex);
psm.setLong(5,getDate(date));
psm.setString(6,description);
psm.executeUpdate();
session.setAttribute( "user ",ID);
response.sendRedirect( "index.jsp ");
}
catch(Exception e){
response.sendRedirect( "register.jsp ");
}
finally
{
if(rs!=null){
try{ rs.close();}catch(Exception e){e.printStackTrace();}
}
if(psm!=null){
try{ psm.close();}catch(Exception e){e.printStackTrace();}
}
if(con!=null){
try{ con.close();}catch(Exception e){e.printStackTrace();}
}
}
%> 不跳转到register.jsp也不跳转到index.jsp
------解决方案--------------------System.out.println( "here ");输出的信息到控制台,确认一下,执行到此段程序了不
------解决方案--------------------帮顶一个。
你用 <%...%> 包括代码,你这些代码都是在.jsp页面下的啊?为什么不放java文件里哦?
你调试一下,一步步走,看是哪行出了问题。
页面空白?那浏览器里的地址是什么?还是原来的地址吗?还是index.jsp?register.jsp?只是没内容?
------解决方案--------------------为什么写在JSP不写道servlet里面呢
------解决方案--------------------你在跳转的语句上面加个输出看看执行没执行