Override your hashCode() function to ensure a different value is returned when form values change. Save the return value of the function and test to see whether it's changed.
public class Person {
String first;
String last;
int prevHash;
@Override
public int hashCode() {
// does not include the value of currHash
String stringHash = String.format("%1$-29s%2$-29s", first,last);
return stringHash.hashCode();
}
}
public class PersonValidator implements Validator {
public void validate(Object obj, Errors e) {
Person p = (Person) obj;
if (p.hashCode() == p.getPrevHash()) {
e.reject("person", "unchanged");
}
}
...
}
I don't think there's a Spring-provided validation test to check whether a form backing object has changed
Note that you could perform additional tests on the client side before allowing the user to submit the form.