What does the @Valid annotation indicate in Spring?

前端 未结 8 1529
隐瞒了意图╮
隐瞒了意图╮ 2020-12-04 20:38

In the following example, the ScriptFile parameter is marked with an @Valid annotation.

What does @Valid annotation do?

<
8条回答
  •  星月不相逢
    2020-12-04 21:30

    public String create(@Valid @NotNull ScriptFile scriptFile, BindingResult result, ModelMap modelMap) {    
        if (scriptFile == null) throw new IllegalArgumentException("A scriptFile is required");        
    

    I guess this @NotNull annotation is valid therefore if condition is not needed.

提交回复
热议问题