★★★★大家来看看这个页面跳转的问题,马上给分★★★★ response.sendRedirect在哪都可以,调试一下你的程序吧,看看status是否得到值了,看看程序是否在执行到response.sendRedirect之前就出错退出了。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 可能是你的查询出错,rs为null.response.sendRedirect在任何地方都有效,不过前提是不要已经有执行的内容返回到客户(被fush())。 javahui(阶级斗争要年年讲,月月讲,天天讲。)是的,我希望当查询为空时也要跳转,可以实现吗? fft123() 我给status赋过初值0了 。 if(!rs.next()){ ...//没有记录跳转}else//有记录{ while(rs.next()) { status=rs.getInt("Status"); } if (status == 1) { response.sendRedirect("../error_page.jsp"); } else { response.sendRedirect("../success_page.jsp"); }.......} 直接写rs==null行不行??if(rs==null){ ...//没有记录跳转} ??什么意思?到什么地方没法跳?设置断点观察一下程序走到哪里了。eg:if(!rs.next()){ out.println("<script>alert('1 here!');history.back();</Script>");//没有记录 return;}if (status == 1){ //response.sendRedirect("../error_page.jsp"); out.println("<script>alert('2 here!');history.back();</Script>"); return;} // userid 后面的值用单引号引起来。 String sql = "select Status from User where userid = '1003'" ResultSet rs = stmt.executeQuery(sql); if (rs != null) { while(rs.next()){ status=rs.getInt("Status"); } if (status == 1){ response.sendRedirect("../error_page.jsp"); } else { response.sendRedirect("../success_page.jsp"); } } esle { response.sendRedirect("../.....jsp"); } https导致servlet无法下载文件 关于lucene在弹出窗口中高亮的问题 大家来帮忙 关于ssh 框架中继承HibernateDaoSupport的问题(补充) 如何在jsf页面第一次显示时将所有输入框灰掉 问个最基本的查询语句的效率问题! JSP翻页问题 怎样改变放置运行JSP文件的目录 [学习]在Java中向Excel文件写入内容 问一个关于response.sendRedirect的问题,急 有关strut2的框架的原理 需要win2000下可将.bat或.exe转换成系统服务的工具,谁有烦劳提供下载 是使用javabean好,还是直接import进class比较。
是的,我希望当查询为空时也要跳转,可以实现吗?
我给status赋过初值0了 。
{
...//没有记录跳转
}
else//有记录
{
while(rs.next())
{
status=rs.getInt("Status");
}
if (status == 1)
{
response.sendRedirect("../error_page.jsp");
}
else
{
response.sendRedirect("../success_page.jsp");
}
.......
}
{
...//没有记录跳转
}
什么意思?到什么地方没法跳?设置断点观察一下程序走到哪里了。eg:if(!rs.next())
{
out.println("<script>alert('1 here!');history.back();</Script>");//没有记录
return;
}
if (status == 1)
{
//response.sendRedirect("../error_page.jsp");
out.println("<script>alert('2 here!');history.back();</Script>");
return;
}
String sql = "select Status from User where userid = '1003'" ResultSet rs = stmt.executeQuery(sql);
if (rs != null) {
while(rs.next()){ status=rs.getInt("Status");
}
if (status == 1){
response.sendRedirect("../error_page.jsp");
} else {
response.sendRedirect("../success_page.jsp");
}
} esle {
response.sendRedirect("../.....jsp");
}