Announcement Announcement Module
Collapse
No announcement yet.
How to override custom error message for spring security Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to override custom error message for spring security

    I want to override custom error message in jsp for spring security authentication exceptions.

    For wrong username/password,
    default : Bad credentials
    override to : Username/Password entered is incorrect.

    I work with spring security sample (spring-security-samples-contacts-3.1.0.RC2.war)
    and do follow http://static.springsource.org/sprin...l#localization step but it doesn't work

    Here is modify configuration in contacts-servlet.xml
    Code:
    <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
            <property name="basename" value="myMessages"/>
    </bean>
    and put myMessages.properties in WEB-INF\classes

    Please help ... I don't sure i forgot or missing something ?

  • #2
    Make sure that the message source configuration is in the same context as spring security is being bootstrapped in, else spring security cannot see the newly configured message source.

    Comment


    • #3
      Thank Marten, But I try it by replace (applicationContext-common-business.xml)
      Code:
      <bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
            <property name="basename" value="classpath:org/springframework/security/messages"/>
      </bean>
      to
      Code:
      <bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
            <property name="basename" value="myMessages"/>
      </bean>
      It still no anything change, I work on sample in spring-security-3.1.0.RC2 version.
      ... Any advice ?

      Comment


      • #4
        hey,
        just do like what martein said
        just place that Resourcebundle bean configuration in spring security.xml .it will work

        Comment


        • #5
          Make sure the message content are correctly inserted as spring security is being bootstrapped in, else spring security cannot see the newly configured message source.

          Comment

          Working...
          X