Thymeleaf Neither BindingResult nor plain target object for bean name 'person' available as request attribute

后端 未结 3 967
再見小時候
再見小時候 2021-01-01 01:08

From what I can tell this is set up correctly but I am getting the following error:

java.lang.IllegalStateException: Neither BindingResult nor plain target 
         


        
3条回答
  •  轮回少年
    2021-01-01 01:36

    Model attribute has to be initialized (using GET method) before calling post method. In your case you need one more method in controller which does model.addAttribute("person",new Person()); and it has to be called before post.

    Refer below link: https://spring.io/guides/gs/handling-form-submission/ OR http://forum.thymeleaf.org/Neither-BindingResult-nor-plain-target-object-for-bean-name-miniDoniie-available-as-request-attribute-td4027859.html

    It has GetMapping as well as PostMapping in controller.

提交回复
热议问题