Spring http/web 转发不适用于 spring-reactive
Spring http/web forward not working with spring-reactive
我正在尝试将请求从一个控制器转发到另一个控制器,但我却收到异常
java.lang.IllegalStateException: Could not resolve view with name
'forward:/test2'. at
org.springframework.web.reactive.result.view.ViewResolutionResultHandler.lambda$resolveViews(ViewResolutionResultHandler.java:272)
~[spring-web-reactive-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
这是我的控制器:
@Controller
class TestController {
@RequestMapping(value="/test")
public String showTestPage() {
return "forward:/test2";
}
}
@RestController
public class TestController2 {
@RequestMapping(value="/test2")
public String showTestPage() {
return "testPageView";
}
}
我正在使用 spring-boot
springBootVersion = '2.0.0.BUILD-SNAPSHOT'
compile('org.springframework.boot.experimental:spring-boot-starter-web-reactive')
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
UrlBasedViewResolver
的文档指出,为了转发到另一个视图,您需要使用 redirect:
前缀,而不是 "forward:"
目前不支持。
请在 https://jira.spring.io 上创建一个新问题(项目:Spring 框架,组件:反应式)。有些概念并没有真正映射到反应世界,所以我不是 100% 确定这应该被实施。
我正在尝试将请求从一个控制器转发到另一个控制器,但我却收到异常
java.lang.IllegalStateException: Could not resolve view with name 'forward:/test2'. at org.springframework.web.reactive.result.view.ViewResolutionResultHandler.lambda$resolveViews(ViewResolutionResultHandler.java:272) ~[spring-web-reactive-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
这是我的控制器:
@Controller
class TestController {
@RequestMapping(value="/test")
public String showTestPage() {
return "forward:/test2";
}
}
@RestController
public class TestController2 {
@RequestMapping(value="/test2")
public String showTestPage() {
return "testPageView";
}
}
我正在使用 spring-boot
springBootVersion = '2.0.0.BUILD-SNAPSHOT' compile('org.springframework.boot.experimental:spring-boot-starter-web-reactive')
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
UrlBasedViewResolver
的文档指出,为了转发到另一个视图,您需要使用 redirect:
前缀,而不是 "forward:"
目前不支持。
请在 https://jira.spring.io 上创建一个新问题(项目:Spring 框架,组件:反应式)。有些概念并没有真正映射到反应世界,所以我不是 100% 确定这应该被实施。