PDA

View Full Version : Spring Mvc 3 hasErrors is always false



imran
Sep 23rd, 2011, 05:32 AM
I have following class,

public class MarketPlace {

@NotEmpty(message="This Template Name is required")
@Size(max=50)
private String templateName;

public String getTemplateName() {
return templateName;
}
}

With the following post method,

@RequestMapping(value = "/PublishApplication.htm", method = RequestMethod.POST)
public String PublishForm(@Valid MarketPlace m, BindingResult result, Map model) {
if (result.hasErrors()) {
return "PublishApplication";
}
return "PublishApplication";
}

But hasErrors is always false? why? Is I need any further configuration?

p792
Sep 23rd, 2011, 08:48 AM
if (result.hasErrors()) {
return "PublishApplication";
}
return "PublishApplication";
}


Can you double check to make sure the method HasError always returns false? I suggest put something inside that "if block".

imran
Sep 23rd, 2011, 09:43 AM
if (result.hasErrors()) {
return "PublishApplication";
}
return "PublishApplication";
}


Can you double check to make sure the method HasError always returns false? I suggest put something inside that "if block".

Yes. This is always false.
I have put a break point here.