Class MvcConfig

  • All Implemented Interfaces:
    org.springframework.web.servlet.config.annotation.WebMvcConfigurer

    @Configuration
    @EnableConfigurationProperties({SecurityProperties.class,SetupProperties.class,WebmasterProperties.class})
    public class MvcConfig
    extends java.lang.Object
    implements org.springframework.web.servlet.config.annotation.WebMvcConfigurer
    Enables localisation support and loads the extra properties for Spring's application.properties files
    • Constructor Summary

      Constructors 
      Constructor Description
      MvcConfig()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addInterceptors​(org.springframework.web.servlet.config.annotation.InterceptorRegistry registry)
      Adds the above interceptor bean to the application’s interceptor registry
      org.springframework.validation.Validator getValidator()
      To use the validation messages from the properties file during model validation we need to register the message source above to the local validator bean
      org.springframework.web.servlet.i18n.LocaleChangeInterceptor localeChangeInterceptor()
      An interceptor bean which allows for changing the current locale on every request based on the value of the "lang" parameter appended to a request
      org.springframework.web.servlet.LocaleResolver localeResolver()
      Used to determine which locale is currently being used and sets the default
      org.springframework.context.MessageSource messageSource()
      Spring delegates the message resolution to this bean and ReloadableResourceBundleMessageSource resolves messages from the resource bundle (messages.properties) for each locale
      org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder passwordEncoder()
      Create a password encoder bean that uses the BCrypt strong hashing function
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface org.springframework.web.servlet.config.annotation.WebMvcConfigurer

        addArgumentResolvers, addCorsMappings, addFormatters, addResourceHandlers, addReturnValueHandlers, addViewControllers, configureAsyncSupport, configureContentNegotiation, configureDefaultServletHandling, configureHandlerExceptionResolvers, configureMessageConverters, configurePathMatch, configureViewResolvers, extendHandlerExceptionResolvers, extendMessageConverters, getMessageCodesResolver
    • Constructor Detail

      • MvcConfig

        public MvcConfig()
    • Method Detail

      • passwordEncoder

        @Bean
        public org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder passwordEncoder()
        Create a password encoder bean that uses the BCrypt strong hashing function
        Returns:
        the PasswordEncoder implementation
      • localeResolver

        @Bean
        public org.springframework.web.servlet.LocaleResolver localeResolver()
        Used to determine which locale is currently being used and sets the default
        Returns:
        the session based locale resolver
      • localeChangeInterceptor

        @Bean
        public org.springframework.web.servlet.i18n.LocaleChangeInterceptor localeChangeInterceptor()
        An interceptor bean which allows for changing the current locale on every request based on the value of the "lang" parameter appended to a request
        Returns:
        the interceptor object
      • addInterceptors

        public void addInterceptors​(org.springframework.web.servlet.config.annotation.InterceptorRegistry registry)
        Adds the above interceptor bean to the application’s interceptor registry
        Specified by:
        addInterceptors in interface org.springframework.web.servlet.config.annotation.WebMvcConfigurer
        Parameters:
        registry - which helps with configuring a list of mapped interceptors
      • messageSource

        @Bean
        public org.springframework.context.MessageSource messageSource()
        Spring delegates the message resolution to this bean and ReloadableResourceBundleMessageSource resolves messages from the resource bundle (messages.properties) for each locale
        Returns:
        the implementation of the MessageSource interface
      • getValidator

        @Bean
        public org.springframework.validation.Validator getValidator()
        To use the validation messages from the properties file during model validation we need to register the message source above to the local validator bean
        Specified by:
        getValidator in interface org.springframework.web.servlet.config.annotation.WebMvcConfigurer
        Returns:
        the local validator bean with the validation message source set