2 u011510931 u011510931 于 2017.01.02 14:00 提问

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]

5个回答

devmiao
devmiao   Ds   Rxr 2017.01.02 21:30

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

dangzhizheng
dangzhizheng   2017.03.08 16:35

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

silencecyn
silencecyn   2017.11.23 01:58

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

u011510931
u011510931   2017.01.02 13:58

页面

名称
JE_GE
JE_GE   2017.01.02 15:17

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

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!