Version: org.springframework:spring-webflux:5.3.21
Problem: When I use RenderingResponse.create("redirect:/controller").status(HttpStatus.FOUND).build()
, the response status is not modified (remains 303 See Other
no matter what).
(.status(something)
works fine on a non-redirect view: RenderingResponse.create("template").status(something).build()
.)
Expected Behavior: When I modify the status of a "redirect view", I expect the status to be as directed in the invocation.
Actual Behavior: The redirect works fine. However, its status is 303 See Other
no matter what I set it to.
I have a router:
@Configuration
class CVRouter(private val controller: CVController) {
@Bean
fun route() = router {
path("/cvs").nest {
GET("", controller::list)
GET("new", controller::new)
POST("", controller::create)
}
}
}
and a controller:
@Component
class CVController(val repository: CVRepository) {
fun list(request: ServerRequest) = RenderingResponse
.create("cv/list")
.modelAttribute("cvs", repository.findAll())
.build()
fun new(request: ServerRequest) = RenderingResponse
.create("cv/new")
.modelAttribute("cv", CV(name = "Test Name"))
.build()
// This does not create anything yet, only testing PRG (Post/Redirect/Get) pattern.
fun create(request: ServerRequest) = RenderingResponse
.create("redirect:/cvs")
.status(HttpStatus.FOUND)
.build()
}