Hi everyone, I'm new to Spring and I know this question has been asked all over the place, but I can't get any answers to work for me. I'm using Spring 3.1.1 and I'm trying to do simple validation on my form. When my form is submitted, my validation class gets called correctly and populates the BindingResult. So I can see the errors in my controller in the BindingResult variable, but I can't see them when I reload the view.
Here is my JSP:
Form Controller:Code:<form:form commandName="formControls" method="POST"> ... <div class="field" id="payer_name"> <label>Number:</label> <span class="input"> <form:input path="payerName" autocomplete="off"/> <form:errors path="payerName"/> <span class="help-text"></span> </span> </div>
Spring Config:Code:@RequestMapping(method = RequestMethod.POST) public String onSubmit(@ModelAttribute("FormControls") FormControls formControls, BindingResult validationResult, ModelMap model) { formValidator.validate(formControls, validationResult); if(validationResult.hasErrors()) { model.addAttribute(formControls); return "manualEntry"; }
So my validation class is working fine because I can see the errors in the validationResult variable. My view is reloading when I return it. I just must have something set up wrong to see the errors in my view. Any help would be great!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:aop="http://www.springframework.org/schema/aop" xmlns:p="http://www.springframework.org/schema/p" xmlns:jaxws="http://cxf.apache.org/jaxws" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd" default-autowire="byName"> <!-- Use annotations (@Autowired) for property injection --> <context:annotation-config /> <!-- Spring will find all of our service and DAO components because they have @Service, @Repository, and @Controller annotations. We do not need to configure them in XML --> <context:component-scan base-package="com.cerner.edi.billpay.**" /> <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/> <property name="prefix" value="/WEB-INF/jsp/"/> <property name="suffix" value=".jsp"/> </bean> <bean class="org.springframework.context.support.ResourceBundleMessageSource" id="messageSource"> <property name="basename" value="messages" /> </bean> </beans>


Reply With Quote
