Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

Here is an issue I have been stuck into. Actually, I implemented all required features in order to get couple of my field validated, however I still get that 400 error. I even compared what I have made with examples from Spring 3 for Professionals (taking their sourcecode); their examples work perfectly, and failed to find difference... :((( - maybe it is due to lack of attention again.

So, here is couple of fields properly annoted to be validated:

@NotEmpty(message="{validation.firstname.NotEmpty.message}") 
@Size(min=3, max=60, message="{validation.firstname.Size.message}")
@Column(name = "FirstName") 
public String getFirstName() { 
    return firstName;
}

@NotEmpty(message="{validation.lastname.NotEmpty.message}") 
@Size(min=1, max=40, message="{validation.lastname.Size.message}")
@Column(name = "LastName") 
public String getLastName() { 
    return lastName;
}

Their messages within messages.properties:

validation.firstname.NotEmpty.message=First name is required
validation.lastname.NotEmpty.message=Last name is required
validation.firstname.Size.message=First name must be between {min} and {max}
validation.lastname.Size.message=Last name must be between {min} and {max}

And yes, messages.properties is reachable, since I successfully get amother message related to success saving.

Here are related parts of methods within controller:

public String update(@Valid Employee employee,...
public String create(@Valid Employee employee,...

i.e. I put required @Valid annotation there.

Then part of my servlet-context.xml:

<annotation-driven validator="validator"/>

<beans:bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean"> 
    <beans:property name="validationMessageSource" ref="messageSource"/> 
</beans:bean>

Here is related part of my edit.jspx

<form:label path="firstName"> ${labelEmployeeFirstName}* </form:label> 

<form:input path="firstName" /> 
<div> <form:errors path="firstName" cssClass="error" /> </div> 
<p/> 

<form:label path="lastName">${labelEmployeeLastName}* </form:label> 

<form:input path="lastName" /> 
<div> <form:errors path="lastName" cssClass="error" /> </div> 

I don't know whether something else required to put here to clarify more...

share|improve this question
    
Error 400 means your request is wrong checkupdown.com/status/E400.html –  Karna Jun 13 '13 at 10:11

1 Answer 1

Remove the @Valid annotation from the controller method argument. Does it still give you 400?

share|improve this answer
    
Thank you everybody... the problem has disappeared, unfortunately, I don't know what was the cause, I simply re-wrote some parts of code from the scratch and then everything works smoothly. I cannot reproduce it. –  orionix Jun 13 '13 at 21:08

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.