diff --git a/framework-docs/modules/ROOT/pages/core/beans/basics.adoc b/framework-docs/modules/ROOT/pages/core/beans/basics.adoc index 8c4697771a..ab6562f740 100644 --- a/framework-docs/modules/ROOT/pages/core/beans/basics.adoc +++ b/framework-docs/modules/ROOT/pages/core/beans/basics.adoc @@ -206,18 +206,17 @@ another file or files. The following example shows how to do so: - ---- -In the preceding example, external bean definitions are loaded from three files: -`services.xml`, `messageSource.xml`, and `themeSource.xml`. All location paths are +In the preceding example, external bean definitions are loaded from the files +`services.xml` and `messageSource.xml`. All location paths are relative to the definition file doing the importing, so `services.xml` must be in the same directory or classpath location as the file doing the importing, while -`messageSource.xml` and `themeSource.xml` must be in a `resources` location below the +`messageSource.xml` must be in a `resources` location below the location of the importing file. As you can see, a leading slash is ignored. However, given that these paths are relative, it is better form not to use the slash at all. The contents of the files being imported, including the top level `` element, must diff --git a/framework-docs/modules/ROOT/pages/testing/testcontext-framework/web-scoped-beans.adoc b/framework-docs/modules/ROOT/pages/testing/testcontext-framework/web-scoped-beans.adoc index f716f1d961..6be937f4f2 100644 --- a/framework-docs/modules/ROOT/pages/testing/testcontext-framework/web-scoped-beans.adoc +++ b/framework-docs/modules/ROOT/pages/testing/testcontext-framework/web-scoped-beans.adoc @@ -96,9 +96,7 @@ Kotlin:: The following code snippet is similar to the one we saw earlier for a request-scoped bean. However, this time, the `userService` bean has a dependency on a session-scoped `userPreferences` bean. Note that the `UserPreferences` bean is instantiated by using a -SpEL expression that retrieves the theme from the current HTTP session. In our test, we -need to configure a theme in the mock session managed by the TestContext framework. The -following example shows how to do so: +SpEL expression that retrieves an attribute from the current HTTP session. .Session-scoped bean configuration [source,xml,indent=0,subs="verbatim,quotes"] diff --git a/framework-docs/modules/ROOT/pages/web/webmvc/mvc-servlet/sequence.adoc b/framework-docs/modules/ROOT/pages/web/webmvc/mvc-servlet/sequence.adoc index 427a4d0ec1..c0ceb61fd5 100644 --- a/framework-docs/modules/ROOT/pages/web/webmvc/mvc-servlet/sequence.adoc +++ b/framework-docs/modules/ROOT/pages/web/webmvc/mvc-servlet/sequence.adoc @@ -11,8 +11,6 @@ The `DispatcherServlet` processes requests as follows: * The locale resolver is bound to the request to let elements in the process resolve the locale to use when processing the request (rendering the view, preparing data, and so on). If you do not need locale resolving, you do not need the locale resolver. -* The theme resolver is bound to the request to let elements such as views determine - which theme to use. If you do not use themes, you can ignore it. * If you specify a multipart file resolver, the request is inspected for multiparts. If multiparts are found, the request is wrapped in a `MultipartHttpServletRequest` for further processing by other elements in the process. See xref:web/webmvc/mvc-servlet/multipart.adoc[Multipart Resolver] for further diff --git a/framework-docs/src/main/kotlin/org/springframework/docs/web/webmvc/mvcconfig/mvcconfiginterceptors/WebConfiguration.kt b/framework-docs/src/main/kotlin/org/springframework/docs/web/webmvc/mvcconfig/mvcconfiginterceptors/WebConfiguration.kt index c2f6d8daba..9bbb738f3a 100644 --- a/framework-docs/src/main/kotlin/org/springframework/docs/web/webmvc/mvcconfig/mvcconfiginterceptors/WebConfiguration.kt +++ b/framework-docs/src/main/kotlin/org/springframework/docs/web/webmvc/mvcconfig/mvcconfiginterceptors/WebConfiguration.kt @@ -14,14 +14,13 @@ * limitations under the License. */ -@file:Suppress("DEPRECATION") package org.springframework.docs.web.webmvc.mvcconfig.mvcconfiginterceptors import org.springframework.context.annotation.Configuration import org.springframework.web.servlet.config.annotation.InterceptorRegistry import org.springframework.web.servlet.config.annotation.WebMvcConfigurer +import org.springframework.web.servlet.handler.UserRoleAuthorizationInterceptor import org.springframework.web.servlet.i18n.LocaleChangeInterceptor -import org.springframework.web.servlet.theme.ThemeChangeInterceptor // tag::snippet[] @Configuration @@ -29,7 +28,7 @@ class WebConfiguration : WebMvcConfigurer { override fun addInterceptors(registry: InterceptorRegistry) { registry.addInterceptor(LocaleChangeInterceptor()) - registry.addInterceptor(ThemeChangeInterceptor()).addPathPatterns("/**").excludePathPatterns("/admin/**") + registry.addInterceptor(UserRoleAuthorizationInterceptor()).addPathPatterns("/**").excludePathPatterns("/admin/**") } } // end::snippet[] \ No newline at end of file diff --git a/framework-docs/src/main/resources/org/springframework/docs/web/webmvc/mvcconfig/mvcconfiginterceptors/WebConfiguration.xml b/framework-docs/src/main/resources/org/springframework/docs/web/webmvc/mvcconfig/mvcconfiginterceptors/WebConfiguration.xml index 2d0f1cae1e..51f91158b4 100644 --- a/framework-docs/src/main/resources/org/springframework/docs/web/webmvc/mvcconfig/mvcconfiginterceptors/WebConfiguration.xml +++ b/framework-docs/src/main/resources/org/springframework/docs/web/webmvc/mvcconfig/mvcconfiginterceptors/WebConfiguration.xml @@ -14,7 +14,9 @@ - + + + diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/HandlerInterceptor.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/HandlerInterceptor.java index 0b63d8b148..f675d41c75 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/HandlerInterceptor.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/HandlerInterceptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,7 +31,7 @@ import org.springframework.web.method.HandlerMethod; *

A HandlerInterceptor gets called before the appropriate HandlerAdapter * triggers the execution of the handler itself. This mechanism can be used * for a large field of preprocessing aspects, or common handler behavior - * like locale or theme changes. Its main purpose is to allow for factoring + * like locale changes. Its main purpose is to allow for factoring * out repetitive handler code. * *

In an asynchronous processing scenario, the handler may be executed in a @@ -75,7 +75,6 @@ import org.springframework.web.method.HandlerMethod; * @see org.springframework.web.servlet.handler.AbstractHandlerMapping#setInterceptors * @see org.springframework.web.servlet.handler.UserRoleAuthorizationInterceptor * @see org.springframework.web.servlet.i18n.LocaleChangeInterceptor - * @see org.springframework.web.servlet.theme.ThemeChangeInterceptor * @see jakarta.servlet.Filter */ public interface HandlerInterceptor { diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/Controller.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/Controller.java index d63c706f34..17d3733320 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/Controller.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/Controller.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,7 +38,7 @@ import org.springframework.web.servlet.ModelAndView; *

Workflow

* *

After a {@code DispatcherServlet} has received a request and has - * done its work to resolve locales, themes, and suchlike, it then tries + * done its work to resolve locales, and suchlike, it then tries * to resolve a Controller, using a * {@link org.springframework.web.servlet.HandlerMapping HandlerMapping}. * When a Controller has been found to handle the request, the diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/support/RequestContext.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/support/RequestContext.java index c894afc802..8fd54a4425 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/support/RequestContext.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/support/RequestContext.java @@ -54,7 +54,7 @@ import org.springframework.web.util.pattern.PathPatternParser; /** * Context holder for request-specific state, like current web application context, current locale, - * current theme, and potential binding errors. Provides easy access to localized messages and + * and potential binding errors. Provides easy access to localized messages and * Errors instances. * *

Suitable for exposition to views, and usage within JSP's "useBean" tag, JSP scriptlets, JSTL EL, diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/support/RequestContextUtils.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/support/RequestContextUtils.java index b1c7ea0fd3..4a697f5d21 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/support/RequestContextUtils.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/support/RequestContextUtils.java @@ -46,7 +46,7 @@ import org.springframework.web.util.UriComponentsBuilder; * set by the {@link org.springframework.web.servlet.DispatcherServlet}. * *

Supports lookup of current WebApplicationContext, LocaleResolver, - * Locale, ThemeResolver, Theme, and MultipartResolver. + * Locale, and MultipartResolver. * * @author Juergen Hoeller * @author Rossen Stoyanchev diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/tags/ArgumentTag.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/tags/ArgumentTag.java index d3cb6e49a3..c46bb76124 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/tags/ArgumentTag.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/tags/ArgumentTag.java @@ -22,7 +22,7 @@ import org.jspecify.annotations.Nullable; /** * The {@code } tag is based on the JSTL {@code fmt:param} tag. - * The purpose is to support arguments inside the message and theme tags. + * The purpose is to support arguments inside the message tags. * *

This tag must be nested under an argument aware tag. * diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/tags/RequestContextAwareTag.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/tags/RequestContextAwareTag.java index d80038fc00..82f5d5c274 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/tags/RequestContextAwareTag.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/tags/RequestContextAwareTag.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,8 +34,7 @@ import org.springframework.web.servlet.support.RequestContext; *

The {@code RequestContext} instance provides easy access * to current state like the * {@link org.springframework.web.context.WebApplicationContext}, - * the {@link java.util.Locale}, the - * {@link org.springframework.ui.context.Theme}, etc. + * the {@link java.util.Locale}, etc. * *

Mainly intended for * {@link org.springframework.web.servlet.DispatcherServlet} requests; diff --git a/spring-webmvc/src/main/resources/META-INF/spring.tld b/spring-webmvc/src/main/resources/META-INF/spring.tld index a78c582ea0..631d865afb 100644 --- a/spring-webmvc/src/main/resources/META-INF/spring.tld +++ b/spring-webmvc/src/main/resources/META-INF/spring.tld @@ -130,7 +130,7 @@ Argument tag based on the JSTL fmt:param tag. The purpose is to - support arguments inside the spring:message and spring:theme tags. + support arguments inside the spring:message tags. argument org.springframework.web.servlet.tags.ArgumentTag JSP diff --git a/spring-webmvc/src/main/resources/org/springframework/web/servlet/view/freemarker/spring.ftl b/spring-webmvc/src/main/resources/org/springframework/web/servlet/view/freemarker/spring.ftl index a30bf500a5..706c2a6ed8 100644 --- a/spring-webmvc/src/main/resources/org/springframework/web/servlet/view/freemarker/spring.ftl +++ b/spring-webmvc/src/main/resources/org/springframework/web/servlet/view/freemarker/spring.ftl @@ -50,36 +50,6 @@ --> <#macro messageArgsText code, args, text>${springMacroRequestContext.getMessage(code, args, text)?no_esc} -<#-- - * theme - * - * Macro to translate a theme message code into a message. - --> -<#macro theme code>${springMacroRequestContext.getThemeMessage(code)?no_esc} - -<#-- - * themeText - * - * Macro to translate a theme message code into a message, - * using the given default text if no message found. - --> -<#macro themeText code, text>${springMacroRequestContext.getThemeMessage(code, text)?no_esc} - -<#-- - * themeArgs - * - * Macro to translate a theme message code with arguments into a message. - --> -<#macro themeArgs code, args>${springMacroRequestContext.getThemeMessage(code, args)?no_esc} - -<#-- - * themeArgsText - * - * Macro to translate a theme message code with arguments into a message, - * using the given default text if no message found. - --> -<#macro themeArgsText code, args, text>${springMacroRequestContext.getThemeMessage(code, args, text)?no_esc} - <#-- * url * diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/DummyMacroRequestContext.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/DummyMacroRequestContext.java index 6f0c1cf8cd..bbd7b2a9c2 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/DummyMacroRequestContext.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/DummyMacroRequestContext.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,8 +40,6 @@ public class DummyMacroRequestContext { private Map messageMap; - private Map themeMessageMap; - private String contextPath; @@ -54,10 +52,6 @@ public class DummyMacroRequestContext { this.messageMap = messageMap; } - public void setThemeMessageMap(Map themeMessageMap) { - this.themeMessageMap = themeMessageMap; - } - /** * @see org.springframework.web.servlet.support.RequestContext#getMessage(String) @@ -89,36 +83,6 @@ public class DummyMacroRequestContext { return (msg != null ? msg + args : defaultMsg); } - /** - * @see org.springframework.web.servlet.support.RequestContext#getThemeMessage(String) - */ - public String getThemeMessage(String code) { - return this.themeMessageMap.get(code); - } - - /** - * @see org.springframework.web.servlet.support.RequestContext#getThemeMessage(String, String) - */ - public String getThemeMessage(String code, String defaultMsg) { - String msg = this.themeMessageMap.get(code); - return (msg != null ? msg : defaultMsg); - } - - /** - * @see org.springframework.web.servlet.support.RequestContext#getThemeMessage(String, List) - */ - public String getThemeMessage(String code, List args) { - return this.themeMessageMap.get(code) + args; - } - - /** - * @see org.springframework.web.servlet.support.RequestContext#getThemeMessage(String, List, String) - */ - public String getThemeMessage(String code, List args, String defaultMsg) { - String msg = this.themeMessageMap.get(code); - return (msg != null ? msg + args : defaultMsg); - } - public void setContextPath(String contextPath) { this.contextPath = contextPath; } diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/freemarker/FreeMarkerMacroTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/freemarker/FreeMarkerMacroTests.java index 1da663aa06..3287519fd5 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/freemarker/FreeMarkerMacroTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/freemarker/FreeMarkerMacroTests.java @@ -171,26 +171,6 @@ public class FreeMarkerMacroTests { assertThat(getMacroOutput("MESSAGEARGSWITHDEFAULTMESSAGE")).isEqualTo("Hi"); } - @Test - void testTheme() throws Exception { - assertThat(getMacroOutput("THEME")).isEqualTo("Howdy! Mundo!"); - } - - @Test - void testDefaultTheme() throws Exception { - assertThat(getMacroOutput("DEFAULTTHEME")).isEqualTo("hi! planet!"); - } - - @Test - void testThemeArgs() throws Exception { - assertThat(getMacroOutput("THEMEARGS")).isEqualTo("Howdy![World]"); - } - - @Test - void testThemeArgsWithDefaultMessage() throws Exception { - assertThat(getMacroOutput("THEMEARGSWITHDEFAULTMESSAGE")).isEqualTo("Hi!"); - } - @Test void testUrl() throws Exception { assertThat(getMacroOutput("URL")).isEqualTo("/springtest/aftercontext.html"); @@ -291,10 +271,6 @@ public class FreeMarkerMacroTests { msgMap.put("hello", "Howdy"); msgMap.put("world", "Mundo"); rc.setMessageMap(msgMap); - Map themeMsgMap = new HashMap<>(); - themeMsgMap.put("hello", "Howdy!"); - themeMsgMap.put("world", "Mundo!"); - rc.setThemeMessageMap(themeMsgMap); rc.setContextPath("/springtest"); TestBean darren = new TestBean("Darren", 99); diff --git a/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/myplaceholder.properties b/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/myplaceholder.properties index 1d454bdb1a..c6245bf8ec 100644 --- a/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/myplaceholder.properties +++ b/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/myplaceholder.properties @@ -1,4 +1,3 @@ useCodeAsDefaultMessage=false message-file=context-messages objectName=test:service=myservice -theme-base=org/springframework/web/context/WEB-INF/ diff --git a/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/test-theme.properties b/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/test-theme.properties deleted file mode 100644 index 019517d124..0000000000 --- a/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/test-theme.properties +++ /dev/null @@ -1 +0,0 @@ -theme.example2=test-message2 diff --git a/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/theme.properties b/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/theme.properties deleted file mode 100644 index 8e5e4c2614..0000000000 --- a/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/theme.properties +++ /dev/null @@ -1,2 +0,0 @@ -theme.example1=This is a test message in the theme message catalog with no args. -theme.example2=message2 diff --git a/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/theme_en_GB.properties b/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/theme_en_GB.properties deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/theme_en_US.properties b/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/theme_en_US.properties deleted file mode 100644 index cbe5be548d..0000000000 --- a/spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/theme_en_US.properties +++ /dev/null @@ -1 +0,0 @@ -theme.example1=This is a test message in the theme message catalog. \ No newline at end of file diff --git a/spring-webmvc/src/test/resources/org/springframework/web/servlet/view/freemarker/test.ftl b/spring-webmvc/src/test/resources/org/springframework/web/servlet/view/freemarker/test.ftl index b6fb4caf4e..adb4aade4b 100644 --- a/spring-webmvc/src/test/resources/org/springframework/web/servlet/view/freemarker/test.ftl +++ b/spring-webmvc/src/test/resources/org/springframework/web/servlet/view/freemarker/test.ftl @@ -21,18 +21,6 @@ MESSAGEARGS MESSAGEARGSWITHDEFAULTMESSAGE <@spring.messageArgsText "no.such.code", msgArgs, "Hi"/> -THEME -<@spring.theme "hello"/> <@spring.theme "world"/> - -DEFAULTTHEME -<@spring.themeText "no.such.code", "hi!"/> <@spring.themeText "no.such.code", "planet!"/> - -THEMEARGS -<@spring.themeArgs "hello", msgArgs/> - -THEMEARGSWITHDEFAULTMESSAGE -<@spring.themeArgsText "no.such.code", msgArgs, "Hi!"/> - URL <@spring.url "/aftercontext.html"/>