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

  • Home
  • SEARCH
  • 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 6739221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:27:41+00:00 2026-05-26T11:27:41+00:00

Using Spring/SpringMVC 3.0.5 I’ve defined a method in my controller like this: @RequestMapping(params =

  • 0

Using Spring/SpringMVC 3.0.5 I’ve defined a method in my controller like this:

@RequestMapping(params = { "save","!delete" }, method = RequestMethod.POST)
public ModelAndView saveFoo(...
    @ModelAttribute("vo") @Valid DescriptionBuilderVO vo, BindingResult result) {
    ...
    result.rejectValue("foo.sequenceNumber", "foo.builder", new Object[]{vo.getFoo().getSequenceNumber()}, "Sequence Number too high");    vo.getFoo().setSequenceNumber(originalNumber);
    return new ModelAndView(WebConstants.VIEW_BUILDER, "vo", vo);

Notice that I’m attempting to set a value in the VO object inside the controller. The funny thing is that if I do this with @ModelAttribute the new value doesn’t show up. If I remove @ModelAttribute from the method contract, the new value appears exactly as you would think. The problem comes when there are errors, the only way to get the errors is to have the @ModelAttribute in the contract.

BTW my HTML looks like:

HTML

<form:input path="foo.sequenceNumber" id="sequenceNumber" size="4" maxlength="4"/>
<form:errors path="foo.sequenceNumber" cssClass="ui-state-error" />

foo.sequenceNumber = the value the user typed in; when I use @ModelAttribute
foo.sequenceNumber = the value I set in the controller; but I lose any errors

It seems to me that SpringMVC is putting the ModelAttribute VO into a “special” place and passing it back to the jsp but not in an obvious location. Does anyone know how I can get at the VO object in this situation?

  • 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-05-26T11:27:42+00:00Added an answer on May 26, 2026 at 11:27 am

    I’ve tried many different things including the reordering the Valid and ModelAttribute annotations and it doesn’t seem to make a difference.

    In reading the documentation suggested by Pat in the comments it does refer to a special context where the VO is stored. Anyway, if you’re trying anything similar to this I suggest you go about it in a different way perhaps building a completely new VO and passing it back to the view, which is what I did.

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

Sidebar

Related Questions

Using Spring MVC, do interceptors only intercept defined controller mappings or can they also
This is an example of using ThrowawayController in Spring MVC: public class DisplayCourseController implements
So I'm using Spring MVC and in my controller I call several Utility classes.
I am using Spring MVC's charset filter. This is the URL that I use
I am using Spring MVC, and in my Controller, I am setting a standard
In the context of an MVC application (using Spring MVC in this case), given
What is wrong with this configuration? I'm using Spring 3 and Hibernate 3.6 and
I am using the RESTEasy Spring MVC integration (springmvc-resteasy using RestEasy 2.0, Spring 3.0)
I'm using Spring MVC to handle JSON POST requests. Underneath the covers I'm using
I am using spring mvc with Annotations, see the following snippet @RequestMapping(value = /configuration/,

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.