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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:26:15+00:00 2026-06-18T01:26:15+00:00

I was using JSR 303 validation with hibernate validator to have fields validated automatically

  • 0

I was using JSR 303 validation with hibernate validator to have fields validated automatically by specifying @Valid on the controller method. Validation was working fine. I have know added an upload field to the form and have added a @RequestParam(“file”) as a MultipartFile file. Now it works only if all fields are valid on submission otherwise I get a 404 (Bad Request). If I remove the @Valid annotation I get the javax.validation.ConstraintViolationException with all the validation violations with Status 500.

I’m using Spring 3.2

my form:

    <form action="#springUrl("/admin/stores/save")" method="POST" enctype="multipart/form-data">
Name: 
  #springBind( "store.name" )
  <input type="text" 
    name="${status.expression}" 
    value="$!status.value" /><br>
......
   <input type="file" name="file" accept="image/*">

  <input type="submit" value="submit"/>
</form>

Controller:

@RequestMapping(value="/save", method = RequestMethod.POST)
    @Transactional
    public String save(@Valid @ModelAttribute Store store, @RequestParam("file") MultipartFile file, BindingResult bindingResult, ModelMap model) {
        if (bindingResult.hasErrors()) {
            model.addAttribute("message", "Failed");
            model.addAttribute("store", store);
            return "admin/stores/form";
        } else {
                .....
  • 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-18T01:26:16+00:00Added an answer on June 18, 2026 at 1:26 am

    your problem is in method argument order. @ModelAttribute must be followed by BindingResult argument. Look at Spring documentation and check also Example 17.1. Invalid ordering of BindingResult and @ModelAttribute.

    . You also should add MultipartFile to form class (Store) if it is part of it.

    Store {
    
        /* Your other fields */
    
        @NotNull
        private  MultipartFile file;
    
        public MultipartFile getFile() {
            return file;
        }
    
        public void setFile(MultipartFile file) {
            this.file= file;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am validation my beans using hibernate validations (JSR 303).All my validations are working
I'm looking into using JSR-303 with hibernate validator. We would like to be able
I'm using Hibernate validator implementation of JSR 303 to validate some entities in my
I am using Spring validation(JSR 303) in one of the web apps.I have no
I am using Hibernate Validator (HV) as my JSR 303 validator. However, both in
I have a bean to validate using jsr-303 but the BIndingResult returns no error.
I'm using Spring 3 and JSR 303. I have a form backing object whose
I'm using Spring MVC 3 and JSR 303. I have a form backing object
I'm trying to set up JSR-303 validation of forms using Spring MVC. I had
We all know, that Spring MVC integrate well with Hibernate Validator and JSR-303 in

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.