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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T02:38:40+00:00 2026-05-21T02:38:40+00:00

hasError is not working; Spring 3 MVC Validation with Hibernate! Maybe I am not

  • 0

hasError is not working; Spring 3 MVC Validation with Hibernate!

Maybe I am not doing this right but can someone tell me what my hasErrors() is false. I am puttting errors is my form but the hasErrors is never try?

Controaller:

@RequestMapping(value = "/save", method = RequestMethod.POST)
public String processValidatinForm(@ModelAttribute(" article") Article  article,
                BindingResult result) {

                System.out.println("In");

 if (result.hasErrors()) {
                    System.out.println("I found errors");
                       return "addArticle";
                }
                // Add the saved validationForm to the model

                articleService.addArticle( article);
                return "redirect:/articles.html";
            }

Form:
@Entity
@Table(name = “article”)
public class Article {

@Id
@GeneratedValue
@Column(name = "article_id")
private Long articleId;

@NotEmpty
@Size(max = 20)
@Column(name = "article_name", nullable = false, length=20)
private String articleName;

@NotEmpty
@Column(name = "article_desc", nullable = false)
private String articleDesc;

@Column(name = "date_added")
private Date addedDate;

public Article() {      
}

public Long getArticleId() {
    return articleId;
}

public void setArticleId(Long articleId) {
    this.articleId = articleId;
}

public String getArticleName() {
    return articleName;
}

public void setArticleName(String articleName) {
    this.articleName = articleName;
}

public String getArticleDesc() {
    return articleDesc;
}

public void setArticleDesc(String articleDesc) {
    this.articleDesc = articleDesc;
}

public Date getAddedDate() {
    return addedDate;
}

public void setAddedDate(Date addedDate) {
    this.addedDate = addedDate;
}   

}

  • 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-21T02:38:41+00:00Added an answer on May 21, 2026 at 2:38 am

    If JSR-303 validation is setup properly (you have hibernate-validator jar, and <mvc:annoatation-driven />) then you should just use @Valid @ModelAttribute(..) ..

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

Sidebar

Related Questions

how can I get this code to trigger a validation as typing occurs (cf
I am using annotation based validation but for one of the forms I am
Arrg. I can't spot the endless loop in this contact form. The thanks div
I'm doing the spring 3 annotation based controller thing. Problem is, when it fails
As part of a project I'm working on, we're migrating from Velocity to JSP.
Working on a project where a sequential set of methods must be run every
I have build my own custom validation framework for WPF using attribute based validation.
I have a web page with 3 forms on it. Not nested, just one
I'm studying simple machine learning algorithms, beginning with a simple gradient descent, but I've
Good morning, I'm learning MVC using the music store examples on the www.asp.net/mvc page,

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.