zoukankan      html  css  js  c++  java
  • 过滤器、拦截器中重定向无限循环问题解决

    package com.bybo.aca.web.interceptor;
    
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    
    import org.springframework.web.servlet.HandlerInterceptor;
    import org.springframework.web.servlet.ModelAndView;
    
    public class Login implements HandlerInterceptor {
    
        @Override
        public void afterCompletion(HttpServletRequest httpRequest,
                HttpServletResponse httpResponse, Object arg2, Exception arg3)
                throws Exception {
             
        }
    
        @Override
        public void postHandle(HttpServletRequest arg0, HttpServletResponse arg1,
                Object arg2, ModelAndView arg3) throws Exception {
            
    
        }
    
        @Override
        public boolean preHandle(HttpServletRequest request, HttpServletResponse response,
                Object object) throws Exception {
            /*HttpServletRequest httpRequest = (HttpServletRequest) request;  
             HttpServletResponse httpResponse = (HttpServletResponse) response;*/
            String urlString = request.getRequestURI();
                
            ///olForum/forumList.html模拟登录页
         //这个地方要做判断不然会无限循环重定向,即执行过滤器、拦截器很多遍 if(urlString.endsWith("forumList.html")){ return true; } //请求的路径 String contextPath=request.getContextPath(); /*httpRequest.getRequestDispatcher("/olForum/forumList").forward(httpRequest, httpResponse);*/ /*response.sendRedirect(contextPath+"/olForum/forumList.html");*/ response.sendRedirect(contextPath + "/olForum/forumList.html?login=aaa"); return false; /*httpResponse.sendRedirect(httpRequest.getContextPath()+"/olForum/forumList.html"); return;*/ } }
  • 相关阅读:
    c++ const的使用
    C++面向对象程序设计举例
    C++构造函数与析构函数的解析
    inline函数和一般的函数有什么不同
    Linux 脚本为什么会有#!
    Linux 基本概念和操作2
    Linux 基本概念和操作
    ubuntu14.0464位 Ros环境 安装halcon13.01
    数据类型之间的连接和运算
    cmd命令 从C盘转到D盘
  • 原文地址:https://www.cnblogs.com/super-chao/p/6496368.html
Copyright © 2011-2022 走看看