Tengo un error en mi aplicación estoy utilizando thymeleaf
con spring boot
> java.lang.IllegalStateException: Neither BindingResult nor plain
> target object for bean name 'personModel' available as request
> attribute at
> org.springframework.web.servlet.support.BindStatus.<init>(BindStatus.java:144)
> ~[spring-webmvc-4.3.12.RELEASE.jar:4.3.12.RELEASE] at
> org.thymeleaf.spring4.util.FieldUtils.getBindStatusFromParsedExpression(FieldUtils.java:401)
> ~[thymeleaf-spring4-2.1.5.RELEASE.jar:2.1.5.RELEASE] at
> org.thymeleaf.spring4.util.FieldUtils.getBindStatus(FieldUtils.java:328)
> ~[thymeleaf-spring4-2.1.5.RELEASE.jar:2.1.5.RELEASE] at
> org.thymeleaf.spring4.util.FieldUtils.getBindStatus(FieldUtils.java:294)
> ~[thymeleaf-spring4-2.1.5.RELEASE.jar:2.1.5.RELEASE] at
> org.thymeleaf.spring4.processor.attr.AbstractSpringFieldAttrProcessor.processAttribute(AbstractSpringFieldAttrProcessor.java:98)
> ~[thymeleaf-spring4-2.1.5.RELEASE.jar:2.1.5.RELEASE] at
> org.thymeleaf.processor.attr.AbstractAttrProcessor.doProcess(AbstractAttrProcessor.java:87)
> ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE] at
> org.thymeleaf.processor.AbstractProcessor.process(AbstractProcessor.java:212)
> ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE] at
> org.thymeleaf.dom.Node.applyNextProcessor(Node.java:1017)
> ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE] at
> org.thymeleaf.dom.Node.processNode(Node.java:972)
> ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE] at
> org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695)
> ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE] at
> org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668)
> ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE] at
> org.thymeleaf.dom.Node.processNode(Node.java:990)
> ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE] at
> org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695)
> ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE] at
> org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668)
> ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE] at
> org.thymeleaf.dom.Node.processNode(Node.java:990)
> ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE] at
> org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695)
> ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE] at
> org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668)
> ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE] at
> org.thymeleaf.dom.Node.processNode(Node.java:990)
> ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE] at
> org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695)
> ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE] at
> org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668)
> ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE] at
> org.thymeleaf.dom.Node.processNode(Node.java:990)
> ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE] at
> org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695)
> ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE] at
> org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668)
> ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE] at
> org.thymeleaf.dom.Node.processNode(Node.java:990)
> ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE] at
> org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695)
> ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE] at
> org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668)
> ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE] at
> org.thymeleaf.dom.Node.processNode(Node.java:990)
> ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE] at
> org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695)
> ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE] at
> org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668)
> ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE] at
> org.thymeleaf.dom.Node.processNode(Node.java:990)
> ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE] at
> org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695)
> ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE] at
> org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668)
> ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE] at
> org.thymeleaf.dom.Node.processNode(Node.java:990)
> ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE] at
> org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695)
> ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE] at
> org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668)
> ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE] at
> org.thymeleaf.dom.Node.processNode(Node.java:990)
> ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE] at
> org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695)
> ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE] at
> org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668)
> ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE] at
> org.thymeleaf.dom.Node.processNode(Node.java:990)
> ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE] at
> org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695)
> ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE] at
> org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668)
> ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE] at
> org.thymeleaf.dom.Node.processNode(Node.java:990)
> ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE] at
> org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695)
> ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE] at
> org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668)
> ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE] at
> org.thymeleaf.dom.Node.processNode(Node.java:990)
> ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE] at
> org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695)
> ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE] at
> org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668)
> ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE] at
> org.thymeleaf.dom.Node.processNode(Node.java:990)
> ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE] at
> org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695)
> ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE] at
> org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668)
> ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE] at
> org.thymeleaf.dom.Node.processNode(Node.java:990)
> ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE] at
> org.thymeleaf.dom.Document.process(Document.java:93)
> ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE] at
> org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1155)
> ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE] at
> org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1060)
> ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE] at
> org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1011)
> ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE] at
> org.thymeleaf.spring4.view.ThymeleafView.renderFragment(ThymeleafView.java:335)
> ~[thymeleaf-spring4-2.1.5.RELEASE.jar:2.1.5.RELEASE] at
> org.thymeleaf.spring4.view.ThymeleafView.render(ThymeleafView.java:190)
> ~[thymeleaf-spring4-2.1.5.RELEASE.jar:2.1.5.RELEASE] at
> org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1286)
> ~[spring-webmvc-4.3.12.RELEASE.jar:4.3.12.RELEASE] at
> org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1041)
> ~[spring-webmvc-4.3.12.RELEASE.jar:4.3.12.RELEASE] at
> org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:984)
> ~[spring-webmvc-4.3.12.RELEASE.jar:4.3.12.RELEASE] at
> org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:901)
> ~[spring-webmvc-4.3.12.RELEASE.jar:4.3.12.RELEASE] at
> org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
> ~[spring-webmvc-4.3.12.RELEASE.jar:4.3.12.RELEASE] at
> org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861)
> ~[spring-webmvc-4.3.12.RELEASE.jar:4.3.12.RELEASE] at
> javax.servlet.http.HttpServlet.service(HttpServlet.java:635)
> ~[tomcat-embed-core-8.5.23.jar:8.5.23] at
> org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
> ~[spring-webmvc-4.3.12.RELEASE.jar:4.3.12.RELEASE] at
> javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
> ~[tomcat-embed-core-8.5.23.jar:8.5.23] at
En mi controller tengo este método:
@PostMapping("/addperson")
public String addPerson(@ModelAttribute(name="personModel") PersonModel personModel,
Model model){
LOG.info("METHOD: addPerson()--PARAMS:"+personModel.toString());
if (null!= personService.addPerson(personModel)){
model.addAttribute("result", 1);
}else {
model.addAttribute("result",0);
}
return "redirect:/personas/personasMAV";
}
En mi vista tengo esto:
<form role="form" action="" th:action="@{/personas/addperson}"
th:object="${personModel}" method="POST">
<div class="row">
<div class="col-xs-6 col-sm-6 col-md-6">
<div class="form-group">
<input type="text" name="apaPaterno" id="apaPaterno" th:field="*{Appaterno}" class="form-control input-sm"
placeholder="Apellido Paterno" />
</div>
</div>
<div class="col-xs-6 col-sm-6 col-md-6">
<div class="form-group">
<input type="text" name="apaMaterno" id="apaMaterno" th:field="*{Apmaterno}" class="form-control input-sm"
placeholder="Apellido Materno" />
</div>
</div>
<form role="form" action="" th:action="@{/personas/addperson}" th:object="${personModel}" method="POST">
<div class="row">
<div class="col-xs-6 col-sm-6 col-md-6">
<div class="form-group">
<input type="text" name="apaPaterno" id="apaPaterno" th:field="*{Appaterno}" class="form-control input-sm" placeholder="Apellido Paterno" />
</div>
</div>
<div class="col-xs-6 col-sm-6 col-md-6">
<div class="form-group">
<input type="text" name="apaMaterno" id="apaMaterno" th:field="*{Apmaterno}" class="form-control input-sm" placeholder="Apellido Materno" />
</div>
</div>
</div>