Neither BindingResult nor plain target object for bean
当你开发一个项目,如果你选择的是spring MVC 框架,而你在前台使用spring的标签时,那么你有可能出现在这个情况。
javax.servlet.jsp.JspTagException: Neither BindingResult nor plain target object for bean name 'command' available as request attribute
方法:1为抛出异常原因,2为异常解决方法。
1. 原因: 进入spring:bind标签源码你可以看到
Object target = requestContext.getModelObject(beanName);
if (target == null) {
throw new IllegalStateException("Neither BindingResult nor plain target object for bean name '" +
beanName + "' available as request attribute");
}
beanName= <spring:bind path="command.spjg">的绿色部分
如果你是直接对某个页面进行请求,那么request中还没command这个对象
2.
在页面上加上
<jsp:useBean id="command" class="com.ztenc.proj.bean.AFRFOAP" scope="request" ></jsp:useBean>
红色部分填上你的绑定类
PS:虽不明,但觉厉~
以上内容是转载、 接下来是我自己的原创解决方案:
在controller处。加上:
@ModelAttribute
public Product get(@RequestParam(required=false) Long id) {
return id==null?new Product():productService.findOne(id);
}
一切OK
Neither BindingResult nor plain target object for bean的更多相关文章
- SpringMVC java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name
当跳转到一个含有form表单的页面的时候 如<form:form commandName="useCarInfo" 必须要new一个useCarInfo的同名实例给jsp来接 ...
- spring MVC做form提交Neither BindingResult nor plain target object for bean name 'command' available
这两天在做spring3.0 MVC+hibernate3.2的练习中,做简单的form提交, 一直报java.lang.IllegalStateException: Neither BindingR ...
- [springMVC]javax.servlet.jsp.JspTagException: Neither BindingResult nor plain target object for bean
问题描述: 页面使用标签<form:form>进行提交时,出现[springMVC]javax.servlet.jsp.JspTagException: Neither BindingRe ...
- 异常:Neither BindingResult nor plain target object for bean name 'command' available as request attribute
Neither BindingResult nor plain target object for bean name 'command' available as request attribute ...
- javax.servlet.jsp.JspTagException: Neither BindingResult nor plain target object for bean (蛋疼死我了)
1为抛出异常原因,2为异常解决方法. 原因: 进入spring:bind标签源码你可以看到 Object target = requestContext.getModelObject(beanNa ...
- 当使用Spring MVC @Valid对输入框进行验证的时候,可能会遇到以下的异常:Neither BindingResult nor plain target object for bean name ‘mybean’ available as request attribute
转自:https://www.cnblogs.com/wenhulu/p/5555457.html 当使用Spring MVC @Valid对输入框进行验证的时候,可能会遇到以下的异常: Neithe ...
- Neither BindingResult nor plain target object for bean name 'command' available as request attribute
最近用JSR303在表单提交时使用Java Bean Validation验证数据.报错堆栈如下: java.lang.IllegalStateException: Neither BindingRe ...
- Neither BindingResult nor plain target object for bean name 'user' available as request attribute
这个异常是因为jsp页面写错了. 把<form:form></form:form>标签改成普通的标签即可. 应该是第一次访问的时候,user是空的.但springmvc不能是空 ...
- java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'user'
转自: https://blog.csdn.net/Winter_chen001/article/details/77332944
随机推荐
- Mysql函数instr、locate、position VS like
Mysql 大家都会用这样的語法: SELECT `column` FROM `table` where `condition` like `%keyword%’ 事实上,可以使用 locate 和 ...
- redis基础使用
redis分linux,window两个版本分支. redis在window下的使用先下载相关包.下载地址:https://github.com/MSOpenTech/redis/releases 下 ...
- ComponentCount 与 ControlCount 区别
ShowMessage(panel.ComponentCount.ToString); ShowMessage(panel.ControlCount.ToString);componetcou ...
- 【转载】大数据量传输时配置WCF的注意事项
WCF传输数据量的能力受到许多因素的制约,如果程序中出现因需要传输的数据量较大而导致调用WCF服务失败的问题,应注意以下配置: 1.MaxReceivedMessageSize:获取或设置配置了此绑定 ...
- Operate blob data in Oracle via C#
oracle table: CREATE TABLE "SCOTT"."TEST_BLOB" ( "NAME" VARCHAR2 ...
- Eclipse is running in a JRE, but a JDK is required 解决方法(转)
转自:http://comeonbabye.iteye.com/blog/1186239 安装Maven后每次启动出现警告信息: Eclipse is running in a JRE, but a ...
- 浅谈Eclipse寻找JVM(JRE)的顺序机制(转)
转自:http://blog.csdn.net/teedry/article/details/6666850 Eclipse也是一个普通的Java程序,因此必须有一个JRE做为运行环境. ...
- QT报错Error processing
执行命令:qmake modbus_ups_mlrl.pro modbus_ups_mlrl.pro文件内容: TEMPLATE = vclib CONFIG +=qt debug thread QT ...
- C++ MFC获取软件运行目录 (包含软件名)
TCHAR *path = new TCHAR[MAX_PATH]; GetModuleFileName(NULL,path,MAX_PATH); AfxMessageBox(path);
- afterTextChanged() callback being called without the text being actually changed
afterTextChanged() callback being called without the text being actually changed up vote8down votefa ...