In using spring validate, my usage is to annotate the checksum on the Bean, as follows:
Wishclip.java:
@NotNull
@Size (max = 512)
Private String URL;
Then use this in spring controller:
Public responseentity<?> addwish (@Valid @RequestBody wishclipdto wish)
But there is a problem, my demand is that the URL in the WISHCLILP is only required in the create when the incoming check, in the update does not need to pass in, such use will be in the Create and update when the URL is validated.
After Google, spring3.1 supports group-level checksums: http://blog.codeleak.pl/2014/08/validation-groups-in-spring-mvc.html and https:// Narmo7.wordpress.com/2014/04/26/how-to-set-up-validation-group-in-springmvc/.
The changes are as follows:
Define two null interfaces in Wishclip, and then use these two interface on the annotations of the URL
/** Validate only when Create **/
public interface createwish{};
/** Validate only when update **/
public interface updatewish{};
And then use it in the controller:
Public responseentity<?> Addwish (@Validated ({createwish.class}) @RequestBody wishclipdto wish)
Public responseentity<void> Update (@Validated ({updatewish.class}) @RequestBody wishclipdto wish)