Class Configuration
java.lang.Object
de.gustavblass.fsu.fmi.roombooking.configuration.Configuration
- All Implemented Interfaces:
org.springframework.web.servlet.config.annotation.WebMvcConfigurer
@EnableAsync
@Configuration
public class Configuration
extends Object
implements org.springframework.web.servlet.config.annotation.WebMvcConfigurer
Specifies the behaviour of the Spring application.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final @NonNull LocaleDefault language that all pages shall be rendered in if no locale is explicitly specified: German. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription@NonNull org.thymeleaf.TemplateEnginevoidconfigurePathMatch(@NonNull org.springframework.web.servlet.config.annotation.PathMatchConfigurer configurer) Allows trailing slashes, so that appending a/to a path (that is not a file) does not matter.@NonNull org.springframework.web.servlet.LocaleResolverRegisters aRootDirectoryBasedLocaleContextResolveras theLocaleResolver.@NonNull com.transferwise.icu.ICUMessageSourceSets up anICUMessageSourceas theMessageSourceused to translate web pages.@NonNull PathLocaliserpathLocaliser(@NonNull org.springframework.context.MessageSource messageSource) Creates aPathLocalisersuitable to convert translated strings into URIs.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.web.servlet.config.annotation.WebMvcConfigurer
addArgumentResolvers, addCorsMappings, addErrorResponseInterceptors, addFormatters, addInterceptors, addResourceHandlers, addReturnValueHandlers, addViewControllers, configureAsyncSupport, configureContentNegotiation, configureDefaultServletHandling, configureHandlerExceptionResolvers, configureMessageConverters, configureViewResolvers, extendHandlerExceptionResolvers, extendMessageConverters, getMessageCodesResolver, getValidator
-
Field Details
-
DEFAULT_LOCALE
Default language that all pages shall be rendered in if no locale is explicitly specified: German.
-
-
Constructor Details
-
Configuration
public Configuration()
-
-
Method Details
-
configurePathMatch
public void configurePathMatch(@NonNull @NonNull org.springframework.web.servlet.config.annotation.PathMatchConfigurer configurer) Allows trailing slashes, so that appending a/to a path (that is not a file) does not matter. Without this setting,/rooms/would return404even if/roomsexists.- Specified by:
configurePathMatchin interfaceorg.springframework.web.servlet.config.annotation.WebMvcConfigurer- Parameters:
configurer- Used to allow trailing slashes.- Implementation Note:
- The current way of implementation is deprecated, but it's the most straightforward way. Also, the other options appear to be overly difficult to implement.
-
localeResolver
@Bean @NonNull public @NonNull org.springframework.web.servlet.LocaleResolver localeResolver()Registers a
RootDirectoryBasedLocaleContextResolveras theLocaleResolver. This means that the right language – which a page shall be displayed in – is not determined by headers, cookies or URL parameters, but only by the language code included in the respective URL path.Uses
DEFAULT_LOCALEas the standard language.- Returns:
- A
RootDirectoryBasedLocaleContextResolver.
-
messageSource
@Bean @NonNull public @NonNull com.transferwise.icu.ICUMessageSource messageSource()Sets up an
ICUMessageSourceas theMessageSourceused to translate web pages. The advantage of ICU is that it does not just allow arguments, but also plurals. See the ICU-TC home page for reference.Specifies the following base names inside the
i18nresource folder as the source files:errormessagesreservationroomuser- `validation``
@return The
ICUMessageSourceused for i18n (internationalisation).` -
additionalDialects
@Bean @NonNull public @NonNull org.thymeleaf.TemplateEngine additionalDialects()- Returns:
A
TemplateEnginewhich includes- a
SpringSecurityDialectthat enables the use ofsec:authorizein Thymeleaf templates - and a
LayoutDialectto use base layouts.
- a
- See Also:
-
pathLocaliser
@Bean @NonNull public @NonNull PathLocaliser pathLocaliser(@NonNull @NonNull org.springframework.context.MessageSource messageSource) Creates aPathLocalisersuitable to convert translated strings into URIs.- Parameters:
messageSource- Used by the PathLocaliser to resolve given path codes.- Returns:
- The PathLocaliser.
-