Using Spring 3.0.2 and Hibernate Validator 4.0.2.GA
It looks like I have my validator setup correctly, but when I do:
Code:
//some of my imports
import javax.validation.Valid;
import org.springframework.validation.BindingResult;
import org.springframework.web.portlet.bind.annotation.RenderMapping;
@RenderMapping(params = "action=form")
public ModelAndView form(@ModelAttribute("formInfo") @Valid Form info, BindingResult binder){
System.out.println("Errors Found: "+binder.hasErrors());
return new ModelAndView("formSuccess");
}
My binder never has any errors. Yet when I do a:
Code:
validator.validate(info, binder);
System.out.println("Errors Found: "+binder.hasErrors());
It has 3 errors, which is good. My "...-portlet.xml" looks like:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<context:component-scan base-package="example.form" />
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="cache" value="true" />
<property name="viewClass"
value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/html/" />
<property name="suffix" value=".jsp" />
</bean>
<bean id="validator"
class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean"/>
<!-- JSR-303 support will be detected on classpath and enabled automatically -->
<mvc:annotation-driven/>
</beans>
In my libs folder I also have the
- validation-api-1.0.0.GA.jar
- hibernate-validator-4.0.2.GA.jar
Why won't my @Valid load any errors into my BindingResult?
Thanks