I am trying to get a Spring 3.0.2 webmvvis project that is running with new annotated validation support. I have a hibernate unit that is annotated like this:
@Antity @Table (name = "client") Public class client tool serializable {Private constant last long serialversionUID = 1L; @ Id @ original (optional = false) column (name = "customer id", tap = incorrect) @ personal eTiger client id; @ Basic (Optional = False) @ Column (name = "first name", tap = incorrect, length = 45) @ Noteply @ size (minimum = 2, max = 45) Private string first name;
I have turned on mvc annotation support in my application. Tags:
& lt; Mvc: annotation-operated / & gt;
And there is a method in my controller that responds to a form submission:
@RequestMapping (value = "/ addClient.htm") public String AddClient (@ModelAttribute ("Client") @ Wild Client Client, Binding Result Results) {if (result.hasErrors ()) {Return "addClient"; } Service.storeClient (Client); Return "Client Result"; }
When my app loads into the server, I can see in the server log file that it loads a valid:
15 [Http-8084-2] information org.hibernate.validator.util.version - hibernate legalization 4.0.2.gay
The problem I have is that the verifier is not feeling insufficient. I turned on debugger and when I came into the controller method, I have 0 errors in binding processing after submitting an empty form. (Binding result shows that the client object is included in it as a goal.) Then it inserts the record without the id and throws an exception. If I fill an ID but leave the name blank, then it creates a record with ID and blank areas.
& lt; Mvc: annotation-driven / & gt;
should contain ...- servlet.xml
, not in applicationContext.xml
.
Comments
Post a Comment