重定向与转发

时间:2020-01-22 09:04:23   收藏:0   阅读:86

重定向与转发

不使用视图解析器InternalResourceViewResolver, 实现重定向与转发

@Controller
public class ModelTest01 {
    @RequestMapping("/m1/test1")
    public String test1(Model model) {
        model.addAttribute("msg", "大头儿子");
        //return "/WEB-INF/jsp/test.jsp";//默认转发
        //return "forward:/WEB-INF/jsp/test.jsp";//转发
        return "redirect:/index.jsp";//重定向
    }
}

一般还是通过视图解析器拼接并转发, 使用return "redirect:/xxx.jsp" 则不经过视图解析器实现跳转

原文:https://www.cnblogs.com/pinked/p/12227519.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!