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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T03:59:43+00:00 2026-06-05T03:59:43+00:00

I can not get the validation error messages to be showed in JSP page.

  • 0

I can not get the validation error messages to be showed in JSP page. Here is my controller:

@Controller
@RequestMapping("/secure")
@SuppressWarnings({"All"})
public class OperationController {

    @ModelAttribute("crawler/operation")
    public OperationForm operationForm() {
        return new OperationForm();
    }

    @RequestMapping(value = "crawler/operation/create", method = RequestMethod.POST)
    public String processCrawlerOperationForm(@Valid OperationForm operationForm, BindingResult result, Map model) {
        if (result.hasErrors()) {
            HashMap<String, String> errors = new HashMap<String, String>();
            for (FieldError error : result.getFieldErrors()) {
                errors.put(error.getField(), error.getDefaultMessage());
            }
            model.put("errors", errors);
            return "crawler/operation";
        }
        //Some logic
        return "crawler/operation";
    }

}

I am 100% sure that errors exits. I have been debugging this code to be sure that there are errors.

My form class:

public class OperationForm {

    @NotEmpty
    private String operationName;

    @NotEmpty
    private String author;

    @NotEmpty
    private String configurationId;

    public String getOperationName() {
        return operationName;
    }
    //Getters and setters
}

My JSP spring form:

<form:form action="${pageContext.servletContext.contextPath}/secure/crawler/operation/create.htm" commandName="crawler/operation">
    <table border="0" cellspacing="12">
        <tr>
             <td>
                 <spring:message code="application.operationForm.operationName"/>
             </td>
             <td>
                <form:input path="operationName"/>
             </td>
             <td class="error">
                <form:errors path="operationName"/>
             </td>
        </tr>
        <tr>
             <td>
                 <spring:message code="application.operationForm.author"/>
             </td>
             <td>
                <form:input path="author"/>
             </td>
             <td class="error">
                <form:errors path="author"/>
             </td>
        </tr>
        <tr>
             <td>
                 <spring:message code="application.operationForm.configuration"/>
             </td>
             <td>
                <form:input path="configurationId"/>
             </td>
             <td class="error">
                <form:errors path="configurationId"/>
             </td>
        </tr>
        <tr>
             <td>
                 <input class="button" type="submit" value="Vykdyti"/>
             </td>
        </tr>
    </table>
</form:form>

What am I doing wrong?

  • 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-05T03:59:44+00:00Added an answer on June 5, 2026 at 3:59 am

    Instead of looping through the list of errors and inserting them into a model object, just check validate and return the view i.e.

    if(result.hasErrors())
      return "crawler/operation";
    ...
    

    Also, in your controller method, add the @ModelAttribute annotation i.e.

    public String processCrawlerOperationForm(@ModelAttribute("form") @Valid OperationForm operationForm, BindingResult result, Map model)
    

    Make sure the value of the ModelAttribute annotation matches the one you are putting into the model object when you’re displaying the form initially. If you’re using the method above operationForm to generate the model, set it to whatever that value is. I’d change that to a more usable value, Spring might get confused by the /, change it to something simple like “form”.

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

Sidebar

Related Questions

I can not get to make this comparison in this simple code error ..
I simply can not get Visual Studio 2005 to find the System.Configuration.ConfigurationManager class. Here
I can not get logs from some customers, can I use Google Urchin in
I can not get environment at custom target shell. CMakeList.txt set( ENV{TEST_VAR} Hello )
I suppose this is not so hard but I can not get it. For
I have a long label that spans multiple lines and I can not get
In silverlight, I can not get INotifyPropertyChanged to work like I want it to
For the life of me, I can not get matplotlib to display graphs in
i use this method before 1 time. but Now i can not get video
I Have been fiddling with this for hours. I can not get my text

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.