-
Notifications
You must be signed in to change notification settings - Fork 38.6k
Closed
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)type: documentationA documentation taskA documentation task
Milestone
Description
Affects: 6.1
RFE: add a section in WebFlux “View Technologies”
on how to do forward:
and redirect:
.
Currently it's not obvious how to handle these schemes with a multitude of SO posts.
Somehow I think the library should be able to handle it easily.
Aside: redirect:
seems to be available in UrlBasedViewResolver
: but the docs
don't show how to add that to the registry (the docs have a freemarker example
though).
package com.example.demos;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;
@SpringBootApplication
@Controller
public class DemoExodusApplication {
public static void main(String[] args) {
SpringApplication.run(DemoExodusApplication.class, args);
}
@GetMapping("/hello")
Mono<String> hello() {
return Mono.just("forward:/goodbye");
}
@ResponseBody
@GetMapping("/goodbye")
Mono<String> goodbye() {
return Mono.just("{\"message\":\"goodbye\"}");
}
}
Neither of these two patterns work and there is an exception such as:
java.lang.UnsupportedOperationException: Forwards are not currently supported by ThymeleafReactiveViewResolver
at org.thymeleaf.spring6.view.reactive.ThymeleafReactiveViewResolver.resolveViewName(ThymeleafReactiveViewResolver.java:984) ~[thymeleaf-spring6-3.1.2.RELEASE.jar:3.1.2.RELEASE]
Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException:
Without Thymeleaf:
java.lang.IllegalStateException: Could not resolve view with name 'forward:/goodbye'.
at org.springframework.web.reactive.result.view.ViewResolutionResultHandler.lambda$resolveViews$3(ViewResolutionResultHandler.java:275) ~[spring-webflux-6.1.12.jar:6.1.12]
Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException:
Metadata
Metadata
Assignees
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)type: documentationA documentation taskA documentation task