diff --git a/framework-docs/modules/ROOT/pages/core/beans/basics.adoc b/framework-docs/modules/ROOT/pages/core/beans/basics.adoc index 8c4697771ab9..ab6562f740f7 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 f716f1d9612b..6be937f4f22b 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 427a4d0ec139..c0ceb61fd57f 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 c2f6d8daba16..9bbb738f3abe 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 2d0f1cae1ead..51f91158b468 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 0b63d8b148ff..f675d41c75be 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 @@ *

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 @@ * @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 d63c706f34e7..17d3733320de 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 @@ *

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 c894afc8024e..8fd54a4425ad 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 @@ /** * 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 b1c7ea0fd330..4a697f5d2174 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 @@ * 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 d3cb6e49a36e..c46bb7612400 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 @@ /** * 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 d80038fc004d..82f5d5c27432 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 @@ *

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 a78c582ea006..631d865afb51 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 a30bf500a57f..706c2a6ed8a9 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 6f0c1cf8cdb9..bbd7b2a9c23f 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 void setMessageMap(Map messageMap) { 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 String getMessage(String code, List args, String defaultMsg) { 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 1da663aa06d5..3287519fd504 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 @@ void testMessageArgsWithDefaultMessage() throws Exception { 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 @@ private String getMacroOutput(String name) throws Exception { 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 1d454bdb1a25..c6245bf8ec8c 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 019517d124f7..000000000000 --- 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 8e5e4c2614dc..000000000000 --- 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 e69de29bb2d1..000000000000 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 cbe5be548d2f..000000000000 --- 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 b6fb4caf4ea6..adb4aade4b19 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"/>