Spring3 MVC: Validation not working

后端 未结 1 1018
梦毁少年i
梦毁少年i 2021-01-26 02:50

The gender validation is not working. Even if no values are entered in the gender text field, the form is getting validated successfully without throwing any error.

Belo

1条回答
  •  时光取名叫无心
    2021-01-26 03:31

    1) All of the javax constraints include an implicit "or null" in their pass conditions. If you want to catch blanks you need to either add @NotNull, or reconfigure the web binder to bind blank inputs to empty string instead of null.

    2) does not turn on Spring 3 dispatcher servlet auto-config magic. You need to define your own validator bean if you do that. To enable everything to automagically work you need to use .

    0 讨论(0)
提交回复
热议问题