JSP 页面重定向
来源:互联网 发布:安智市场软件下载 编辑:程序博客网 时间:2024/05/16 12:42
JSP 页面重定向
当需要将文档移动到一个新的位置时,就需要使用JSP重定向了。
最简单的重定向方式就是使用response对象的sendRedirect()方法。这个方法的签名如下:
public void response.sendRedirect(String location)throws IOException
这个方法将状态码和新的页面位置作为响应发回给浏览器。您也可以使用setStatus()和setHeader()方法来得到同样的效果:
....String site = "http://www.runoob.com" ;response.setStatus(response.SC_MOVED_TEMPORARILY);response.setHeader("Location", site); ....
实例演示
这个例子表明了JSP如何进行页面重定向:
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%><%@ page import="java.io.*,java.util.*" %><html><html><head><title>页面重定向</title></head><body><h1>页面重定向</h1><% // 重定向到新地址 String site = new String("http://www.runoob.com"); response.setStatus(response.SC_MOVED_TEMPORARILY); response.setHeader("Location", site); %></body></html>
将以上代码保存在PageRedirecting.jsp文件中,然后访问http://localhost:8080/PageRedirect.jsp,它将会把您带至http://www.runoob.cc/。
阅读全文
0 0
- jsp页面重定向
- JSP 页面重定向
- JSP 页面重定向
- JSP 页面重定向
- JSP 页面重定向
- jsp页面response重定向
- JSP/Servlet的页面重定向技术
- jsp示例-response页面重定向
- JSP简单练习-页面重定向
- springmvc 重定向到一个jsp页面
- Jersey实现JSP页面转发和重定向
- JSP和Servlet中的页面跳转和重定向辨析
- JSP中页面的转发与重定向
- jsp重定向
- JSP重定向
- JSP的重定向
- JSP重定向技巧
- JSP的重定向
- rsync + lsyncd 文件实时同步/备份
- String 和StringBuilder的区别
- Host XXX is blocked because of many connection errors, unblock with 'mysqladmin flush-hosts
- 单目/双目与imu的融合(一)
- 死锁现象-Java基础070
- JSP 页面重定向
- EasyCsharp
- Request对象的主要方法
- iOS 从0到1搭建高可用App框架
- Linux 使用pppd和ppp程序进行3G/4G拨号
- 12对象的构造和析构
- LintCode 安排课程
- Zookeeper 安装与配置
- 求知过程之存储过程回滚