Dexter Dexter - 21 days ago 6
Java Question

Spring http/web forward not working with spring-reactive

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);
}
}

Answer

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.