springmvc重定向和转发,配置试图基础上

来源:互联网 发布:淘宝网不能点击购买 编辑:程序博客网 时间:2024/06/07 08:10
    /**     * 测试重定向     */    @RequestMapping(value="/testRedirectOrForward.do",method = RequestMethod.GET)    public String redirect(@RequestParam("id")int id){        if(id==1){            log.info("{}重定向",id);            return "redirect:/static/redirect.jsp";        }else{            log.info("{}转发",id);            return "forward:/static/forward.jsp";        }    }    @RequestMapping(value="/test.do",method = RequestMethod.GET)    public String red(@RequestParam("id") int id){        if(id==1){            return  "redirect:/student/testRedirectOrForward.do?id="+id;        }else{            return "forward:/student/testRedirectOrForward.do?id="+id;        }    }

浏览器中输入ip: http://localhost:8080/student/test.do?id=1
id=1的话会重定向,地址栏会变,不安全
这里写图片描述
id不是1的话是转发
这里写图片描述

原创粉丝点击