无法使用response.sendRedirect重定向 [英] Cannot redirect with the response.sendRedirect
本文介绍了无法使用response.sendRedirect重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我用google搜索并搜索了几个小时,了解如何在jsp或servlet中进行重定向。
但是当我尝试应用它时,它不起作用。
I googled and googled for hours on how to make a redirect in jsp or servlets. However when i try to apply it, it doesn't work.
我在jsp页面内的代码:
Code that i have inside jsp page:
<%
String articleId = request.getParameter("article_id").toString();
if(!articleId.matches("^[0-9]+$"))
{
response.sendRedirect("index.jsp");
}
%>
我从调试中知道regexp有效,如果有的话,articleId不是数字,如果
进入,但是当它到达response.sendRedirect时它实际上没有重定向。
I know from debugging that regexp works and if any time, articleId is not number, the if
goes inside, however when it reaches response.sendRedirect it doesn't actually makes redirect.
我是否会错过一些非常基本的东西在这种情况下?
Do I miss something very fundamental in this case ?
提前致谢。
推荐答案
重定向后你应该返回
:
response.sendRedirect("index.jsp");
return;
这篇关于无法使用response.sendRedirect重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文