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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:11:45+00:00 2026-05-18T01:11:45+00:00

New to Spring here, and after reading the reference docs the workflow to validate

  • 0

New to Spring here, and after reading the reference docs the workflow to validate a simple web form isn’t popping out at me.

Could someone give me a beginners overview of how we go about form validation in Spring 3.0.3 (I’m using a mix of annotations and xml config in a webapp that I’m migrating now). Starting from the Controller, what happens?

For example: so far I think I understand that I should “bind” the form data to an object of my creation (say MyPerson for example), then create a Validation object that accepts MyPerson and uses ValidationUtils to perform the validation.

But that’s all very fuzzy in my head (especially the “binding” concept) and a step by step review of the workflow from someone who’s been through it before would help me be confident that I’m not missing or mis-interpreting any steps.

  • 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-18T01:11:46+00:00Added an answer on May 18, 2026 at 1:11 am

    The method you are mentioning for validating forms is one of a few options you have available.

    As well as the method you have suggested you may also want to investigate using JSR-303 annotations with an appropriate implementation (for example Hibernate Validator). There are a lot of example of how to accomplish this.

    For the spring validation method your basic steps are:

    • Create an class to act as a binding object, pass an instance of this to the view in your controller
    • Bind the object to the fields in your view using the form taglib
    • In the controller method which handles the form submission, use the @ModelAttribute annotation to bind the form data to your binding object
    • Use your custom validator object (probably @Autowired to your controller) to perform validation

    Heres a simple example controller:

    @Controller
    public class PersonController {

    @Autowired
    private PersonValidator personValidator;
    
    @RequestMapping(value="person/form", method = RequestMethod.GET)
    public ModelAndView form() {
        // Instance of binding object
        Person person = new Person();
    
        // Create ModelAndView which displays personForm view
        ModelAndView mav = new ModelAndView("person/form");
        // Put our binding object in the model
        mav.getModel().put("person", person);
    
        return mav;
    }
    
    @RequestMapping(value="person/form", method = RequestMethod.POST)
    public String save(@ModelAttribute Person person, BindingResult errors, Model model) {
        // Call our custom validator and put errors into BindingResult
        personValidator.validate(person, errors);
    
        // If we have validation errors
        if (errors.hasErrors()) {
            // Show form with errors
            return "person/form";
        }
    
        // Otherwise show some success page
        return "person/success";
     }
    

    }

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

Sidebar

Related Questions

after reading the Zend documentation and some posts here I could not figure out
I just joined StackOverflow after having found many great answers here in the past.
Apparently this problem comes up fairly often, after reading Regular expression to detect semi-colon
I've made some new warning settings in eclipse. With these new settings I'm facing
An hour ago I posted an answer here which according to me was correct.
Having followed a tutorial I have a hashtable that contains a TcpClient object that
i have created an xml file from my c# application i want to use
I'm familiar with the Google Maps API and I'm trying to learned the iOS
Does anyone know of an efficient way to do multiple linear regression in C#,

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.