【问题标题】:java.lang.annotation.AnnotationFormatError is happened when i use validation in spring mvcjava.lang.annotation.AnnotationFormatError 当我在 spring mvc 中使用验证时发生
【发布时间】:2018-07-07 11:50:46
【问题描述】:

当我使用验证时,我得到these errors。它找到了错误,但是当我再次返回同一个 jsp 页面时,它会抛出这些异常,否则它可以工作。任何建议将不胜感激。

【问题讨论】:

  • 图像锚的格式
  • neatbeans 发生错误。我不确定我认为这是一个错误。它适用于 sts 和 intellij idea。

标签: java html css spring spring-mvc


【解决方案1】:

发生这种情况是因为您可能已在实体中将 groupspayload 定义为 @NotNull 注释。

并且您的表单提交没有为此提交任何值,因此它会转到null,因此您会遇到这些错误。

最好定义 BindingResult 并控制如下错误。

@RequestMapping(method = RequestMethod.POST, produces = "text/html")
public String create(@Valid EntityPojo entity, BindingResult bindingResult, Model uiModel, HttpServletRequest httpServletRequest) {
    if (bindingResult.hasErrors()) {
        return getPath() + "/update"; //here you return the same page with errors
    }
    //here you proceed further if there is no error
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-04-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-14
    • 1970-01-01
    • 2013-03-05
    相关资源
    最近更新 更多