Results 1 to 5 of 5

Thread: How to override custom error message for spring security

  1. #1
    Join Date
    Aug 2011
    Posts
    2

    Default 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. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,624

    Default

    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.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3
    Join Date
    Aug 2011
    Posts
    2

    Question

    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 ?

  4. #4
    Join Date
    Mar 2012
    Location
    Bangalore,India
    Posts
    2

    Default

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

  5. #5

    Default

    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.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •