文章目录 Springboot实现请求转发和重定向 一、请求转发 方式一:使用forword实现请求转发 方式二:使用servlet 提供的API实现请求转发 二、请求重定向 方式一:使用redirect实现请求重定向 方式二:使用servlet 提供的API实现请求重定向 Springboot实现请求转发和重定向 一、请求转发 方式一:使用forword实现请求转发 @RequestMapping(value="/api/v1/{name}" , method = RequestMethod.GET) public String test(@PathVariable String name) { return "forword:/test/hello.html"; } 注意:类的注解不能使用@RestController 要用@Controller