Reputation: 1750
I am trying to forward a request from one controller to another, but instead I am getting an exception
java.lang.IllegalStateException: Could not resolve view with name 'forward:/test2'. at org.springframework.web.reactive.result.view.ViewResolutionResultHandler.lambda$resolveViews$5(ViewResolutionResultHandler.java:272) ~[spring-web-reactive-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
Here are my controllers :
@Controller
class TestController {
@RequestMapping(value="/test")
public String showTestPage() {
return "forward:/test2";
}
}
@RestController
public class TestController2 {
@RequestMapping(value="/test2")
public String showTestPage() {
return "testPageView";
}
}
I am using 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);
}
}
Upvotes: 4
Views: 1364
Reputation: 59086
This is not supported at the moment.
Please create a new issue on https://jira.spring.io (project: Spring Framework, component: reactive). Some concepts don't really map into the reactive world, so I'm not 100% sure this should be implemented.
Upvotes: 2
Reputation: 28301
The documentation for the UrlBasedViewResolver
states that in order to forward to another view, you need to use the redirect:
prefix, not "forward:"
Upvotes: 2