@RequestMapping({"/someurl"})
public String execute(Model model) {
if (someCondition) {
return "forward:/someUrlA";
} else {
return "forward:/someUrlB";
}
}
我正在尝试将请求从一个 Controller 转发到另一个 Controller 。当我运行它时, Controller 返回字符串作为响应,而不是转发给另一个 Controller ...有人可以指出我遗漏了什么吗?
最佳答案
您可以重定向请求而不是转发。
所以改变你的返回
if (someCondition) {
return "redirect:/someUrlA";
} else {
return "redirect:/someUrlB";
}
关于java - Spring @RequestMapping Controller 转发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28779388/