javascript
1:按钮式:
<INPUT name="pclog" type="button" value="GO" onClick="location.href='http://9ba.cn/'">
2:链接式:
<a href="javascript:history.go(-1)">返回上一步</a>
<a href="<%=Request.ServerVariables("HTTP_REFERER")%>">返回上一步</a>
3:直接跳转式:
<script>window.location.href='http://www.9ba.cn';</script>
4:开新窗口:
<a href="javascript:" onClick="window.open('http://www.9ba.cn/post/235.html','','height=500,width =611,scrollbars=yes,status=yes')">云上的日子</a>
JSP跳转方式
1:response.sendRedirect()
a:此语句前不允许有out.flush(),如果有,会有异常:
java.lang.IllegalStateException: Can't sendRedirect() after data has committed to the client.
at com.caucho.server.connection.AbstractHttpResponse.sendRedirect(AbstractHttpResponse.java:558)
...
b:response.sendRedirect()之前不能有任何HTML输出(和a说的是一回事).因此通常要放到jsp的最前面
2:response.setHeader("Location","")
此语句前不允许有out.flush(),如果有,页面不会跳转。跳转后浏览器地址栏变化 此语句后面的语句执行完成后才会跳转
3:<jsp:forward page="" />
此语句前不允许有out.flush(),如果有,会有异常:
java.lang.IllegalStateException: forward() not allowed after buffer has committed.
at com.caucho.server.webapp.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:134)
at com.caucho.server.webapp.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:101)
at com.caucho.jsp.PageContextImpl.forward(PageContextImpl.java:836)
...
跳转后浏览器地址栏不变,但是只能跳到当前主机下此语句后面的语句执行完成后才会跳转
4:用Header头刷新到重定向页面
out.println("<script>alert(''错误信息'')</script>");
response.setHeader("refresh","1;url=index.jsp");
return;
点击查看原始大小图片
大小: 31.9 KB
原文:http://wentao365.iteye.com/blog/1059296
1:按钮式:
<INPUT name="pclog" type="button" value="GO" onClick="location.href='http://9ba.cn/'">
2:链接式:
<a href="javascript:history.go(-1)">返回上一步</a>
<a href="<%=Request.ServerVariables("HTTP_REFERER")%>">返回上一步</a>
3:直接跳转式:
<script>window.location.href='http://www.9ba.cn';</script>
4:开新窗口:
<a href="javascript:" onClick="window.open('http://www.9ba.cn/post/235.html','','height=500,width =611,scrollbars=yes,status=yes')">云上的日子</a>
JSP跳转方式
1:response.sendRedirect()
a:此语句前不允许有out.flush(),如果有,会有异常:
java.lang.IllegalStateException: Can't sendRedirect() after data has committed to the client.
at com.caucho.server.connection.AbstractHttpResponse.sendRedirect(AbstractHttpResponse.java:558)
...
b:response.sendRedirect()之前不能有任何HTML输出(和a说的是一回事).因此通常要放到jsp的最前面
2:response.setHeader("Location","")
此语句前不允许有out.flush(),如果有,页面不会跳转。跳转后浏览器地址栏变化 此语句后面的语句执行完成后才会跳转
3:<jsp:forward page="" />
此语句前不允许有out.flush(),如果有,会有异常:
java.lang.IllegalStateException: forward() not allowed after buffer has committed.
at com.caucho.server.webapp.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:134)
at com.caucho.server.webapp.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:101)
at com.caucho.jsp.PageContextImpl.forward(PageContextImpl.java:836)
...
跳转后浏览器地址栏不变,但是只能跳到当前主机下此语句后面的语句执行完成后才会跳转
4:用Header头刷新到重定向页面
out.println("<script>alert(''错误信息'')</script>");
response.setHeader("refresh","1;url=index.jsp");
return;
点击查看原始大小图片
大小: 31.9 KB
原文:http://wentao365.iteye.com/blog/1059296