I want to response a type of String as "redirect:http://www.stackoverflow.com" and expected that the browser would auto redirect to the address as what I want. But, it was failed when I use a "@RestController
".(based on SpringBoot 1.3.5.RELEASE)
@RestController
@RequestMapping("/test")
public class TestRestController {
@RequestMapping("/rest_controller")
public String testResponse() {
return "redirect:http://stackoverflow.com/";
}
}
but the following can make the redirect succeed when use "@Controller
".
@Controller
@RequestMapping("/test")
public class TestController {
@RequestMapping("/not_rest_controller")
public String testResponse() {
return "redirect:http://stackoverflow.com/";
}
}
and I want to know how to make the @RestController
also succeed as the @Controller
.