在一个JSP页面里,有段JAVA代码if(Condition1){
response.sendRedirect("xxxxx.jsp");
}
if(Condition2){response.sendRedirect("ooooo.jsp");
}if(Condition3){response.sendRedirect("11111.jsp");
}
我想问的是Condition1条件满足的时候,是直接跳转到xxxxx.jsp,还是代码会运行到Condition3在跳转,我自己认为是Condition1满足后直接跳转页面,但是谨慎的态度来这里问一下,确认一下,很菜的问题,欢迎大家回帖。
response.sendRedirect("xxxxx.jsp");
}
if(Condition2){response.sendRedirect("ooooo.jsp");
}if(Condition3){response.sendRedirect("11111.jsp");
}
我想问的是Condition1条件满足的时候,是直接跳转到xxxxx.jsp,还是代码会运行到Condition3在跳转,我自己认为是Condition1满足后直接跳转页面,但是谨慎的态度来这里问一下,确认一下,很菜的问题,欢迎大家回帖。
解决方案 »
- 关于hibernate分组统计null值的不统计
- struts 标签 <logic:equal>用法 帮忙找找错。
- 问个类的问题
- 把原来的javaweb项目重新部署后打开网页出现错误,什么原因啊
- 怎么在JSP页面里用jstl标签来输出有顺序的set呢?
- 哪位能提供一些spring+hibernate+struts的教程,先谢过了!
- eclipse 项目-->属性-->为什么没有deployment assembly 按钮呢,求大牛解答啊
- jps中这数组怎么用request传到javaBean
- 在errorpage.jsp如何捕获Bean内部的错误?
- 怪事哦???!!!
- 关于数组的问题
- 如何在struts2拦截器中获取spring管理的对象???
if(Condition1){
response.sendRedirect("xxxxx.jsp");
}
else if(Condition2){response.sendRedirect("ooooo.jsp");
}else if(Condition3){response.sendRedirect("11111.jsp");
}
return ;// 加个return jsp 最后还是编译成servert在服务器上执行,所以加上直接返回肯定要好// 我们写servert 代码肯定能直接返回都加了return ,道理是一样的
%>
因为返回值只有1个值//通过接口获得值 a的值是唯一的
Integer a=(Integer)abc接口.getXXX();
//Code为专门存放一些接口返回值的类 里面变量全是static final类型的
if(a.equals(new Integer(Code.Success))){
response.sendRedirect("xxxxx.jsp");
}虽然二楼改成else if比较好一点 但是 这是别人写的代码。
后面的语句会继续执行。
测试如下:
你可以在它下面加入一个输出到控制台的语句:
<%
System.out.print("有输出吗?");
%>
运行即可看到控制台上已经输出了这一语句。
而相对于response的跳转语句,如果使用
<jsp:forward page="url"/>
则直接跳转,其后的语句不被执行。