重转向保留跳转过来的Referer,路径不会变
1 request.getRequestDispatcher("/eventweb/index.sp?loginId=" + loginId).forward(request, response);
重定向的 第一种方式         

       PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<script>");
out.println("window.open ('" + request.getContextPath() + "/eventweb/declare.sp?loginId=" + loginId + "','_top')");
out.println("</script>");
out.println("</html>")
重定向的 第二种方式,跳转时以post方式提交(如果get会展示携带的参数,不安全)

1   RedirectWithPost redirectWithPost = new RedirectWithPost(response);
String redirectUrl = request.getContextPath() + "/eventweb/declare.sp";
redirectWithPost.setParameter("loginId", loginId);
redirectWithPost.sendByPost(redirectUrl);
/**
* 用POST方式 重定向
*
* @author royFly
*/
public class RedirectWithPost {
Map<String, String> parameter = new HashMap<String, String>();
HttpServletResponse response; public RedirectWithPost(HttpServletResponse response) {
this.response = response;
} public void setParameter(String key, String value) {
this.parameter.put(key, value);
} public void sendByPost(String url) throws IOException {
this.response.setContentType("text/html");
PrintWriter out = this.response.getWriter();
out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
out.println("<HTML>");
out.println(" <HEAD>");
out.println(" <meta http-equiv=Content-Type content=\"text/html; charset=utf-8\">");
out.println(" <TITLE>loading</TITLE>");
out.println(" <meta http-equiv=\"Content-Type\" content=\"text/html charset=GBK\">\n");
out.println(" </HEAD>");
out.println(" <BODY>");
out.println("<form name=\"submitForm\" action=\"" + url + "\" method=\"post\">");
Iterator<String> it = this.parameter.keySet().iterator();
while (it.hasNext()) {
String key = it.next();
out.println("<input type=\"hidden\" name=\"" + key + "\" value=\"" + this.parameter.get(key) + "\"/>");
}
out.println("</from>");
out.println("<script>window.document.submitForm.submit();</script> ");
out.println(" </BODY>");
out.println("</HTML>");
out.flush();
out.close();
}
}

重定向的 第三种方式

sendRedirect(request, response, url, true);

重定向和转向的写法,重定向以post方式提交的更多相关文章

  1. Python第十天 print >> f,和fd.write()的区别 stdout的buffer 标准输入 标准输出 从控制台重定向到文件 标准错误 重定向 输出流和输入流 捕获sys.exit()调用 optparse argparse

    Python第十天   print >> f,和fd.write()的区别    stdout的buffer  标准输入 标准输出  从控制台重定向到文件  标准错误   重定向 输出流和 ...

  2. layui 时间插件,change&&done,按照官网写法无效,解决方式!

    摘抄自 hahei2020:https://blog.csdn.net/hahei2020/article/details/79285370 layui 时间插件, 当选择时间或时间发生改变后,按照官 ...

  3. iis里URL重写重定向,http做301重定向https

    上一篇文章写了iis和apache共用80端口,IIS代理转发apache. 因为第一次配置,这中间还是碰到了很多问题.这里记录下来,希望以后能避免错误. 使用Application Request ...

  4. jQuery插件写法总结以及面向对象方式写法总结

    前两个是jQuery插件,后面2个是以对象的形式开发,都类似. 写法一 (function($, window){ // 初始态定义 var _oDialogCollections = {}; // ...

  5. Servlet路径跳转1---使用相对路径和绝对路径,在页面上调用servlet的路径写法(超链接的方式和表单的方式)

    课程1-13   http://www.imooc.com/video/5554 Servlet路径跳转: 绝对路径:放在任何地方都对的路径 相对路径:相对于当前资源的路径 index文件 加上/,表 ...

  6. [转]jQuery插件写法总结以及面向对象方式写法

    本文转自:http://www.xuanfengge.com/jquery-plug-in-written-summary-and-summary-of-writing-object-oriented ...

  7. HttpClient相关

    HTTPClient的主页是http://jakarta.apache.org/commons/httpclient/,你可以在这里得到关于HttpClient更加详细的信息 HttpClient入门 ...

  8. HttpClient,DefaultHttpClient使用详解

    HttpClient:是一个接口 首先需要先创建一个DefaultHttpClient的实例 HttpClient httpClient=new DefaultHttpClient(); 发送GET请 ...

  9. httpclient详细介绍

    1.HttpClient简介 HttpClient 是 Apache Jakarta Common 下的子项目,可以用来提供高效的.最新的.功能丰富的支持 HTTP 协议的客户端编程工具包,并且它支持 ...

随机推荐

  1. k3 cloud成本调整单提示期末余额不存在调整单分录的维度,请先出库核算确认是否存在核算维度的数据

    成本调整单提示期末余额不存在调整单分录的维度,请先出库核算确认是否存在核算维度的数据,如下图所示: 解决办法:先做出库核算,然后做成本调整单,再做出库核算(出库成本核算)

  2. USTC现代软件工程--summary

    起笔:我希望先简单总结一下我在这门课程中经历的一些工作以及学习到的一些东西,再对自己.队友.老师做一个评价.然后我想提出一些对这门课程的一些看法和建议,与自己的心得体会. 第一部分: 我在这门课上经历 ...

  3. python浮点数与整数间的转化

    舍弃小数部分 >>> math.trunc(12.533222) 12 >>> round(12.2544) 12 按给定小数位数四舍五入 >>> ...

  4. lvm相关知识

    参考资料: 1.https://www.cnblogs.com/mchina/p/linux-centos-logical-volume-manager-lvm.html#top

  5. Go(三)面向对象

    封装数据和行为 数据封装 结构定义 type Employee struct { Id string Name string Age int } field后面没有逗号 实例创建及初始化 e := E ...

  6. 51nod 1714:B君的游戏(博弈 sg打表)

    题目链接:https://www.51nod.com/onlineJudge/questionCode.html#!problemId=1714 nim游戏的一个变形,需要打出sg函数的表 #incl ...

  7. mysql 查询所有子节点

    SELECT t3.college_code FROM ( SELECT t1.college_code, IF ( find_in_set( t1.parent_org_code, , ) AS i ...

  8. 一款易用、高可定制的vue翻页组件

    一款易用.高可定制的vue翻页组件 在线体验:pages.cixi518.com 使用 npm i vo-pages --save vo-pages组件父元素必须设置固定高度并填写属性overflow ...

  9. 03 spring security执行流程分析

    spring security主要是依赖一系列的Filter来实现权限验证的,责任链设计模式是跑不了的.下面简单记录一下spring操作这些Filter的过程. 1. WebSecurityConfi ...

  10. PHP array_change_key_case() 函数

    实例 将数组的所有的键转换为大写字母: <?php $age=array("Peter"=>"35","Ben"=>&qu ...