美文网首页
forward和redirect

forward和redirect

作者: 油条沾豆浆 | 来源:发表于2017-12-07 11:50 被阅读0次

如果/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";

}

相关文章

网友评论

      本文标题:forward和redirect

      本文链接:https://www.haomeiwen.com/subject/fnrdixtx.html