文档章节

springMVC报错 Neither BindingResult nor plain ta....

philonic
 philonic
发布于 2016/01/12 12:05
字数 501
阅读 470
收藏 0

tomcat报错如下:

2016-01-12 11:41:39,238 ERROR [web.servlet.tags.form.InputTag] - Neither BindingResult nor plain target object for bean name 'mlisBasicinfo' available as request attribute

java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'mlisBasicinfo' available as request attribute

at org.springframework.web.servlet.support.BindStatus.<init>(BindStatus.java:144)

at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getBindStatus(AbstractDataBoundFormElementTag.java:168)

at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getPropertyPath(AbstractDataBoundFormElementTag.java:188)

at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getName(AbstractDataBoundFormElementTag.java:154)

at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.autogenerateId(AbstractDataBoundFormElementTag.java:141)

at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.resolveId(AbstractDataBoundFormElementTag.java:132)

at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.writeDefaultAttributes(AbstractDataBoundFormElementTag.java:116)

at org.springframework.web.servlet.tags.form.AbstractHtmlElementTag.writeDefaultAttributes(AbstractHtmlElementTag.java:422)

at org.springframework.web.servlet.tags.form.InputTag.writeTagContent(InputTag.java:142)

at org.springframework.web.servlet.tags.form.AbstractFormTag.doStartTagInternal(AbstractFormTag.java:84)

at org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag(RequestContextAwareTag.java:80)

at org.apache.jsp.business.modules.database.mlisBasicinfoList_jsp._jspx_meth_form_005finput_005f0(mlisBasicinfoList_jsp.java:488)

at org.apache.jsp.business.modules.database.mlisBasicinfoList_jsp._jspService(mlisBasicinfoList_jsp.java:226)

at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)

at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)

at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)

at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61)

at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)

at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)

at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)

at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)

at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)

at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)

at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)

at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)

at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)

at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)

at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)

at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344)

at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)

at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)

at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)

at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)

at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)

at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)

at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)

at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)

at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)

at java.lang.Thread.run(Unknown Source)

一月 12, 2016 11:41:39 上午 org.apache.catalina.core.StandardWrapperValve invoke

严重: Servlet.service() for servlet [jsp] in context with path [/ycinfo] threw exception [An exception occurred processing JSP page /business/modules/database/mlisBasicinfoList.jsp at line 78


75:     <form:form id="searchForm" modelAttribute="mlisBasicinfo" action="" method="post" class="breadcrumb form-search">

76:         <ul class="ul-form">

77:             <li><label>参数名称:</label>

78:                 <form:input path="basicinfoName" htmlEscape="false" maxlength="64" class="input-xlarge"/>

79:             </li>

80:             <li><label>参数类型:</label>

81:                 <form:select path="basicinfoType" class="input-xlarge">



Stacktrace:] with root cause

java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'mlisBasicinfo' available as request attribute

原因:form表单中的modelAttribute="mlisBasicinfo" 无法获取到,加载页面是直接到jsp页面,没有modelAttribute,

解决:先经过controller类,再到jsp页面的,可在controller类中添加@ModelAttribute 的get方法


@ModelAttribute

    public MlisBasicinfo get(@RequestParam(required = false) String id) {

        MlisBasicinfo entity = null;

        if (StringUtils.isNotBlank(id)) {

            entity = mlisBasicinfoService.get(id);

        }

        if (entity == null) {

            entity = new MlisBasicinfo();

        }

        return entity;

    }


© 著作权归作者所有

共有 人打赏支持
philonic

philonic

粉丝 4
博文 34
码字总数 71311
作品 0
后端工程师
私信 提问
加载中

评论(1)

philonic
philonic
http://www.cnblogs.com/zhaoyang/archive/2012/01/07/2315403.html
springmvc 数据绑定 validate

springmvc数据绑定,做验证时,方式应该如下写: public String add(@Valid User user,BindingResult binding),里面要有处理验证结果的BindResult如果没有加,像如下这样: public String ...

菠萝啊哈哈
2014/07/09
0
0
使用SpringMVC的@Validated注解验证

1、SpringMVC验证@Validated的使用 第一步:编写国际化消息资源文件 编写国际化消息资源ValidatedMessage.properties文件主要是用来显示错误的消息定制 [java] view plain copy edit.userna...

瑟青豆
06/22
0
0
Spring MVC的@RequestMapping注解的方法签名异常

病理特征:Errors/BindingResult argument declared without preceding model attribute. Check your handler method signature 堆栈信息:忘了^_^... 自从使用Spring框架以后,笔者再也没有用......

李长春
2011/09/15
0
1
【补充】Hibernate validator使用和自定义validator及整合Spring MVC

Hibernate validator使用 导入validation-api-xxx.jar 以及 hibernate-validator-xxx.Final.jar 需要检查的java bean Entity.java 值校验的测试类 输出结果 这里有一个国际化的key值,国际化文...

jason_wu_2
2016/12/27
387
0
springMVC 高级2 之 valadation

1 validation Spring3支持JSR-303验证框架,JSR-303 是JAVA EE 6 中的一项子规范,叫做Bean Validation,官方参考实现是Hibernate Validator(与Hibernate ORM 没有关系),JSR 303 用于对J...

龙之天空
2015/11/16
0
0

没有更多内容

加载失败,请刷新页面

加载更多

高并发编程:解析HashMap

底层实现原理 在JDK1.8以前版本中,HashMap的实现是数组+链表,它的缺点是即使哈希函数选择的再好,也很难达到元素百分百均匀分布,而且当HashMap中有大量元素都存到同一个桶中时,这个桶会有...

小刀爱编程
33分钟前
0
0
程序员请不要假装很努力,因为结果不会陪你演戏

前言: 我一直相信这样一句话:真正的危机,来源于在正确的时间做不正确的事。没有在正确的时间,为下一步做出积累,这才是危机的根源。 比如,当你迈过了30岁这个坎,你的能力还局限于程序的...

Java干货分享
38分钟前
2
0
Fio随机读IOPS测试值可能偏大的原因分析

问题描述: 在使用fio进行虚拟机磁盘(Ceph的RBD,格式化为ext4文件系统)的IOPS测试时,发现randread比预估值高许多; 在使用相同参数进行randwrite测试之后,再进行randread时会出现此现象...

LastRitter
42分钟前
2
0
JavaScript引用类型Object常见用法实例分析

1、JavaScript数据类型 (1)基本类型 5种基本类型:Undefined、Null、Boolean、Number、String (2)引用类型 5种引用类型:Object、Array、Date、RepExp、Function (3)基本类型与引用类型的异同...

peakedness丶
49分钟前
1
0
教你理清SpringBoot与SpringMVC的关系

spring boot就是一个大框架里面包含了许许多多的东西,其中spring就是最核心的内容之一,当然就包含spring mvc。spring mvc 是只是spring 处理web层请求的一个模块。因此他们的关系大概就是这...

别打我会飞
54分钟前
2
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部