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 9094077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T23:15:49+00:00 2026-06-16T23:15:49+00:00

I’m using Spring 3.1.1.RELEASE. I’m having trouble getting error messages to display on my

  • 0

I’m using Spring 3.1.1.RELEASE. I’m having trouble getting error messages to display on my JSP. Here’s the method I’m using in my controller …

@RequestMapping(value = "/save", method = RequestMethod.POST)
public ModelAndView save(final HttpServletRequest request,
                         final Organization organization,
                         final Model model,
                         final BindingResult result) 
{
    String nextPage = "organizations/add";
    m_orgValidator.validate(organization, result);
    if (!result.hasErrors())
    {
        final boolean isUpdate = !StringUtils.isEmpty(organization.getId()); 
        // We need this clause to prevent detached entity errors.
        if (StringUtils.isEmpty(organization.getId()))
        {
            organization.setId(null);
        }   // if
        m_orgSvc.save(organization);
        final String msgKey = isUpdate ? "org.updated.successfully" : "org.added.successfully"; 
        final Object[] args = new Object[0];
        request.setAttribute(STATUS, 
                             MessageFormat.format(resourceBundle.getString(msgKey), args));

        nextPage = "landing";
    } else { 
        model.addAttribute(ORG_MODEL_NAME, organization);
    }   // if

    return new ModelAndView(nextPage);
}   // save

And here’s my JSP …

    <c:url var="action" value="/organizations/save" />
    <form:form modelAttribute="org" method="post" action="${action}">
        <form:hidden path="id" />
        <fieldset>
            <legend>Upload Fields</legend>
            <p><form:errors path="*" cssClass="error" /></p>
            <p>
                <form:label for="name" path="name">Name *</form:label><br/>
                <form:input path="name" type="text"/>
            </p>

I’ve verified through debugging that my validator is setting errors properly (result.hasErrors() = true), but errors are not displaying properly on my page. Any ideas? Below is my validator class if that helps.

@Component
public class OrgValidator implements Validator
{

    @Autowired
    private OrganizationService m_orgSvc;

    …

    public boolean supports(Class<?> clazz)
    {
        return Organization.class.isAssignableFrom(clazz);
    }

    public void validate(final Object target,
                         final Errors errors)
    {
        final Organization org = (Organization) target;

        if (org != null && !StringUtils.isEmpty(org.getEodbId()))
        {
            final String eodbId = org.getEodbId();
            final Organization foundOrg = m_orgSvc.findByEodbId(eodbId);
            if ((org.getId() == null && foundOrg != null) ||
                (org.getId() != null && foundOrg != null && !org.getId().equals(foundOrg.getId())))
            {
                errors.rejectValue("eodbId", "AlreadyExists.org.eodb.id");
            }   // if
        } else if (org == null || org != null && StringUtils.isEmpty(org.getEodbId())) { 
            errors.rejectValue("eodbId", "NotExists.org.eodb.id");   
        }   // if

        if (org == null || org.getOrganizationType() == null)
        {
            errors.rejectValue("organizationType", "Invalid.org.type");
        }   // if

        if (org == null || org.getCountry() == null)
        {
            errors.rejectValue("country", "Invalid.org.country");
        }   // if

        if (org == null || org.getState() == null)
        {
            errors.rejectValue("state", "Invalid.org.state");
        }   // if
    }

}
  • 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-16T23:15:50+00:00Added an answer on June 16, 2026 at 11:15 pm

    The reason is that the BindingResult gets bound as a request attribute with a name which ends with .organization and tries to retrieve it with this suffix, whereas your model attribute name is org and that is the reason why it is not able to find the errors for your model.

    The fix is to name your model attribute organization and to use this name in the jsp also:

    model.addAttribute("organization", organization);
    
    
    <form:form modelAttribute="organization" method="post" action="${action}">
            <p><form:errors path="*" cssClass="error" /></p>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
We're building an app, our first using Rails 3, and we're having to build
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I am using JSon response to parse title,date content and thumbnail images and place
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am using the SimpleRSS gem to parse a WordPress RSS feed. The only
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
In my XML file chapters tag has more chapter tag.i need to display chapters

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.