springboot 重定向
时间: 2023-09-05 21:13:46 浏览: 186
在 Spring Boot 中,可以使用 RedirectView 类来实现重定向。
1. 在 Controller 中使用 RedirectView:
```java
@GetMapping("/old-url")
public RedirectView redirect() {
return new RedirectView("/new-url");
}
```
2. 在 Thymeleaf 模板中使用重定向:
```html
<meta http-equiv="refresh" content="0;url=/new-url" />
```
3. 在 JSP 页面中使用重定向:
```html
<% response.sendRedirect("/new-url"); %>
```
以上三种方式都可以实现重定向,具体使用哪种方式取决于你的需求和场景。
阅读全文
相关推荐


