zoukankan      html  css  js  c++  java
  • springmvc 退出清除session,返回首页,获取当前项目路径,返回前台ajax输出 东师理想

    @RequestMapping(value="/logout",method=RequestMethod.GET)
           public void logout(HttpServletRequest request,HttpServletResponse response)
           {
               //清除session
            Enumeration<String> em = request.getSession().getAttributeNames();
            while(em.hasMoreElements()){
                request.getSession().removeAttribute(em.nextElement().toString());
            }
            request.getSession().invalidate();
            //获取项目真实路径 
               String path = request.getContextPath();
              //拼接跳转页面路径
               String basePath = request.getScheme() + "://"
                      + request.getServerName() + ":" + request.getServerPort()
                      + path + "/";
              //刷新页面
            String str = "<script>top.location='"+basePath+"'</script>";
            System.out.println(str);
            responseTxt(response,str); 
           }
    //返回前台页面ajax
    protected void responseTxt(HttpServletResponse response,String str){
            try {
                response.setContentType("text/html;charset=UTF-8");
                PrintWriter out = response.getWriter();
                out.write(str);
                out.flush();
                out.close();
            } catch (Exception e) {
                e.printStackTrace();
            }        
        }
  • 相关阅读:
    SqlHelper
    C#中gridView常用属性和技巧介绍
    oracle中的存储过程例子
    log4j.properties配置详解
    Ant之build.xml
    jQuery源码
    jQuery实现分页
    mysql中log
    SQL只获取字段中的中文字符
    子Repeater获取父级Repeater绑定项的值
  • 原文地址:https://www.cnblogs.com/cczhoufeng/p/2948330.html
Copyright © 2011-2022 走看看