thymeleaf / thymeleaf-spring

Thymeleaf integration module for Spring
http://www.thymeleaf.org
Apache License 2.0
434 stars 156 forks source link

Allow hiding model attributes in redirects #299

Open fabien-chebel opened 2 years ago

fabien-chebel commented 2 years ago

Context

Spring Web MVC allows performing redirections by returning a String prefixed by redirect:// in the controller.

This String is intercepted by ThymeleafViewResolver which maps it to an instance of RedirectView.

Problem

The default behaviour of RedirectView is to include all model attributes as query parameters.

This behaviour may not be desirable and thymeleaf-spring does not provide a way to easily change it.

Suggested fix

Expose a method called setRedirectExposeModelAttributes in ThymeleafViewResolver to allow overriding this behaviour.