springBoot+thymeleaf访问时报错!!!! 4C

图片说明

@RequestMapping("/")
public String index(){
        return "/helloThymeleaf";
}

@RequestMapping(value="/findDept",method=RequestMethod.POST)
public String findDept(Dept dept,Model model){
    System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!");
    Dept dept1 = deptDao.findByDeptNo(dept.getDeptNo());
    model.addAttribute("deptList",dept1);
    return "/helloThymeleaf";
}

输入localhost:8080后报错

报错信息

java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'Dept' available as request attribute
at org.springframework.web.servlet.support.BindStatus.(BindStatus.java:144) ~[spring-webmvc-4.3.5.RELEASE.jar:4.3.5.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]

6个回答

页面

名称

th:object=${Dept}没有这个值

: Neither BindingResult nor plain target object for bean name 'Dept' available as request attribute
没找到dept属性

哥们,你的问题解决了没,什么原因

兄弟,我也遇到这个问题了,找了好久都没找到解决办法。
网络上找到,都和我们一样,但是别人就是没有异常。
我怀疑是thymeleaf或者spring版本的问题。
找到解决办法的话,麻烦发个帖告知一下,谢谢。

是不是 ${dept} d小写,变量

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问