码迷,mamicode.com
首页 > 编程语言 > 详细

spring mvc重定向

时间:2018-06-19 18:55:33      阅读:153      评论:0      收藏:0      [点我收藏+]

标签:mod   bsp   重定向   height   www   style   com   mode   throws   

spring mvc重定向有三种方法。

1.return new ModelAndView("redirect:/toUrl"); 其中/toUrlt是你要重定向的url.

2.return "redirect:/toUrl";

@RequestMapping("/ssss")
public String testRedSSS(HttpServletResponse response) throws Exception{
System.out.println("ssss");
return "redirect:http://www.qq.com";
}

 

3.用response.sendRedirect()方法。

public void testRed(HttpServletResponse response) throws Exception{
  response.sendRedirect("https://www.baidu.com");
}

注意,如果要跳转到别的项目,如上所示,要写完整的地址,加上http。

spring mvc重定向

标签:mod   bsp   重定向   height   www   style   com   mode   throws   

原文地址:https://www.cnblogs.com/roy-blog/p/9200578.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!