Rob Winch opened SPR-14537 and commented

Here is a scenario I find it very useful:

Someone is using Spring Security and we need to present the user with an "authentication prompt". Often times this will vary by content type. So for example, I might need to return an HTTP Basic prompt for application/json but redirect to an HTML page for html request. In the json case the result might even contain some JSON in the body giving the error message.

If we support a concept like forward, this can make it easy to define a Spring @RequestMapping endpoint to process it. This means that the user can easily leverage things like type conversion, argument resolvers, etc.

Otherwise, (as far as I can tell) Spring Security must provide support for all these things or handicap the user with a less flexible API.

I do acknowledge having different "dispatch" types adds quite a bit of complexity, so that might not be worth the tradeoff. However, I thought it was worth bringing up for discussion

Rossen Stoyanchev points out that this would be useful in error handling (i.e. similar to global error handler "forwards" to a controller).


Affects: 5.0 M1

Issue Links: - #20367 Improve WebExceptionHandler mechanism

1 votes, 6 watchers

Comment From: spring-projects-issues

Spencer Gibb commented

Spring Cloud Netflix uses this as a feature, Spring Cloud Gateway (based on WebFlux) would like to provide a similar feature where the proxy routes internally rather than externally.

Comment From: spring-projects-issues

wang guobo commented

I have implemented view forwarding feature in webflux controller, see this fork view forwarding in webflux.

Comment From: bclozel

We were considering this as an option when WebFlux was created and decided to keep things simple for a start, as forward dispatches can add complexity to the entire model. In the meantime, we managed to implement lots of features and provide WebFlux support without adding this.

Let's decline this issue, as introducing this concept now is not likely to improve existing support and will add more complexity.

Comment From: spencergibb

In gateway, we end up injecting the Dispatch Handler and using it directly