如果/hello就是某个controller的映射,想要转发这个controller。
可以通过forward 前缀来达到转发到其它资源的目的:
publicString handle() {
// return "forward:/hello" => 转发到能够匹配 /hello 的 controller 上
// return "hello" => 实际上还是转发,只不过是框架会找到该逻辑视图名对应的 View 并渲染
// return "/hello" => 同 return "hello"
return"forward:/hello";
}
通过redirect 前缀来达到重定向到其它资源的目的:
publicString handle() {
// 重定向到 /hello 资源
return"redirect:/hello";
}
网友评论