diff --git a/thymeleaf-spring5/src/main/java/org/thymeleaf/spring5/view/ThymeleafViewResolver.java b/thymeleaf-spring5/src/main/java/org/thymeleaf/spring5/view/ThymeleafViewResolver.java index 4cc78214..9a94f5a4 100755 --- a/thymeleaf-spring5/src/main/java/org/thymeleaf/spring5/view/ThymeleafViewResolver.java +++ b/thymeleaf-spring5/src/main/java/org/thymeleaf/spring5/view/ThymeleafViewResolver.java @@ -91,6 +91,7 @@ public class ThymeleafViewResolver private boolean redirectContextRelative = true; private boolean redirectHttp10Compatible = true; + private boolean redirectExposeModelAttributes = true; private boolean alwaysProcessRedirectAndForward = true; @@ -523,8 +524,35 @@ public void setRedirectHttp10Compatible(final boolean redirectHttp10Compatible) public boolean isRedirectHttp10Compatible() { return this.redirectHttp10Compatible; } - - + + + /** + *

+ * Set whether model attributes should be appended to the URI, when performing a redirection. + *

+ * + * @param redirectExposeModelAttributes true if model attributes should be appended to the redirect URI, + * false if not + * @see RedirectView#setExposeModelAttributes(boolean) + */ + public void setRedirectExposeModelAttributes(final boolean redirectExposeModelAttributes) { + this.redirectExposeModelAttributes = redirectExposeModelAttributes; + } + + + /** + *

+ * Return whether model attributes should be appended to the URI, when performing a redirection. + *

+ * + * @return whether model attributes should be appended to the URI, when performing a redirection. + * @see RedirectView#setExposeModelAttributes(boolean) + * + */ + public boolean shouldRedirectExposeModelAttributes() { + return this.redirectExposeModelAttributes; + } + /** *

@@ -775,7 +803,7 @@ protected View createView(final String viewName, final Locale locale) throws Exc if (viewName.startsWith(REDIRECT_URL_PREFIX)) { vrlogger.trace("[THYMELEAF] View \"{}\" is a redirect, and will not be handled directly by ThymeleafViewResolver.", viewName); final String redirectUrl = viewName.substring(REDIRECT_URL_PREFIX.length(), viewName.length()); - final RedirectView view = new RedirectView(redirectUrl, isRedirectContextRelative(), isRedirectHttp10Compatible()); + final RedirectView view = new RedirectView(redirectUrl, isRedirectContextRelative(), isRedirectHttp10Compatible(), shouldRedirectExposeModelAttributes()); return (View) getApplicationContext().getAutowireCapableBeanFactory().initializeBean(view, REDIRECT_URL_PREFIX); } // Process forwards (to JSP resources) diff --git a/thymeleaf-spring6/src/main/java/org/thymeleaf/spring6/view/ThymeleafViewResolver.java b/thymeleaf-spring6/src/main/java/org/thymeleaf/spring6/view/ThymeleafViewResolver.java index b1eaccb9..832b7274 100755 --- a/thymeleaf-spring6/src/main/java/org/thymeleaf/spring6/view/ThymeleafViewResolver.java +++ b/thymeleaf-spring6/src/main/java/org/thymeleaf/spring6/view/ThymeleafViewResolver.java @@ -91,6 +91,7 @@ public class ThymeleafViewResolver private boolean redirectContextRelative = true; private boolean redirectHttp10Compatible = true; + private boolean redirectExposeModelAttributes = true; private boolean alwaysProcessRedirectAndForward = true; @@ -525,6 +526,33 @@ public boolean isRedirectHttp10Compatible() { } + /** + *

+ * Set whether model attributes should be appended to the URI, when performing a redirection. + *

+ * + * @param redirectExposeModelAttributes true if model attributes should be appended to the redirect URI, + * false if not + * @see RedirectView#setExposeModelAttributes(boolean) + */ + public void setRedirectExposeModelAttributes(final boolean redirectExposeModelAttributes) { + this.redirectExposeModelAttributes = redirectExposeModelAttributes; + } + + + /** + *

+ * Return whether model attributes should be appended to the URI, when performing a redirection. + *

+ * + * @return whether model attributes should be appended to the URI, when performing a redirection. + * @see RedirectView#setExposeModelAttributes(boolean) + * + */ + public boolean shouldRedirectExposeModelAttributes() { + return this.redirectExposeModelAttributes; + } + /** *

@@ -775,7 +803,7 @@ protected View createView(final String viewName, final Locale locale) throws Exc if (viewName.startsWith(REDIRECT_URL_PREFIX)) { vrlogger.trace("[THYMELEAF] View \"{}\" is a redirect, and will not be handled directly by ThymeleafViewResolver.", viewName); final String redirectUrl = viewName.substring(REDIRECT_URL_PREFIX.length(), viewName.length()); - final RedirectView view = new RedirectView(redirectUrl, isRedirectContextRelative(), isRedirectHttp10Compatible()); + final RedirectView view = new RedirectView(redirectUrl, isRedirectContextRelative(), isRedirectHttp10Compatible(), shouldRedirectExposeModelAttributes()); return (View) getApplicationContext().getAutowireCapableBeanFactory().initializeBean(view, REDIRECT_URL_PREFIX); } // Process forwards (to JSP resources)