Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8014087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T19:49:30+00:00 2026-06-04T19:49:30+00:00

First, let me explain that I’m using Spring MVC 3.1.1, and Hibernate validation 4.2.0.

  • 0

First, let me explain that I’m using Spring MVC 3.1.1, and Hibernate validation 4.2.0. I’m using validation annotations for various forms in my Spring application. Since my application needs to be localized, I’ve been using a resource bundle for my validation messages that looks somewhat like this:

# ValidationMessages.bundle
FieldMatch=Password and confirmation must match.

The corresponding class definition for this message looks like this:

@FieldMatch.List({
    @FieldMatch(first = "password", second = "passwordConfirmation")
})
public class RegistrationForm {
    // ...
}

I have this custom resource bundle set up in my appContext.xml, and my messages are being shown on the form without any issue.

Here’s my dilemma, however. There is a new requirement that I must confirm more fields match. Right now I’m just confirming that two password fields match. Now my requirement is that I have to confirm email address too. I know this is a silly requirement, but I can’t change it. So now the class definition will look like this:

@FieldMatch.List({
    @FieldMatch(first = "password", second = "passwordConfirmation")
    @FieldMatch(first = "email", second = "emailConfirmation")
})
public class RegistrationForm {
    // ...
}

Clearly, my current resource bundle will not work because I need two separate messages (one for each match). I’ve tried using message="{emails.must.match}" and then defining that message in the resource bundle, but it never actually shows the message, it just shows the actual text {email.must.match}.

So after all that explaining, my question is simple: How can I make each one of those FieldMatch validators at the class level have a different message that is defined in a resource bundle so it can be localized?

Thanks in advance for any help!

[EDIT] For those curious, this is the FieldMatch validator that I’m using.

UPDATE 5/23/2012
Here’s the bean definition others have asked for:

<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
    <property name="basenames">
        <list>
            <value>ErrorBundle</value>
            <value>ForgotPasswordBundle</value>
            <!-- etc etc -->
        </list>
    </property>
</bean>

<bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean">
    <property name="validationMessageSource" ref="messageSource"/>
</bean>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T19:49:31+00:00Added an answer on June 4, 2026 at 7:49 pm

    Cases like this usually turn on something the OP did not include in the question. I guess this is because if the solution were simple or caused by something the OP thought it was caused by, they wouldn’t have a problem. No judgment; I’ve done it.

    So I present troubleshooting steps instead of a complete solution, because based on what you’ve said, it should work.

    First, let’s double check that it’s not a weird interpolation problem and try message="{emails-must-match}".

    If that doesn’t work, well, it appears you used to have ValidationMessages.properties working. I’d go back to that (removing <property name="validationMessageSource" ref="messageSource"/> from the validator config) and see if you can get message="{emails.must.match}" to work with emails.must.match defined in ValidationMessages.properties. If that still doesn’t work, go back to the default message you had using the key FieldMatch and see if you get that message for both error conditions.

    That will help localize the problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First let me explain. I have several addresses on the page that I put
First let me explain how I currently handle validation, say, for an IPv4 address:
First let me explain that I've created a million lib directories scouring out all
That's the first time i get an error like this one, let me explain
Let me first explain what I'm trying to achieve using some pseudo-code (JavaScript). //
First let me explain that I have this script that should let users enter
First off, let me explain that I am well aware of what this exception
Let me explain the problem: Various pages of my web application contain jQuery UI
First let me explain that I am on a hosted solution, and there is
First let me explain that I am on a hosted solution, and there is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.