[springMVC]javax.servlet.jsp.JspTagException: Neither BindingResult nor plain target object for bean
问题描述:
页面使用标签<form:form>进行提交时,出现[springMVC]javax.servlet.jsp.JspTagException: Neither BindingResult nor plain target object for bean...异常。
原因分析:
1、渲染页面时,<form:form>标签有一个默认属性commandName,其值默认为”command"。其实这个command就是对应controller中的javabean。但我的controller的方法中对应的javabean名并不是command,而是user或account等等。所以要显式指定其commandName值为"user"或你用的javabean的名。(也可指定其modelAttribute属性的值,与指定commandName效果是一样的)
2、另外,产生这个问题的还有可能是controller中拦截的方法中没有将javabean加入到ModelMap对象中,即没有东西与页面的commandName那个名字对应起来
解决办法:
页面:
<form:form commandName="user" action="" method="get">/*commandName是你自己的javabean的对象名*/
</form:form>
Controller:
public String showProjects(ModelMap model){
model.addAttribute("user",new User());//这里user与commandName的值对应
//do something...
return "...";
}
熟悉spring mvc或其他标签库的规则,才能更好地去进行页面和controller下的交互。(其实不管你用的是spring的tag还是jstl,渲染后的结果就是html,并没有超越html范畴的东西。)
[springMVC]javax.servlet.jsp.JspTagException: Neither BindingResult nor plain target object for bean的更多相关文章
- javax.servlet.jsp.JspTagException: Neither BindingResult nor plain target object for bean (蛋疼死我了)
1为抛出异常原因,2为异常解决方法. 原因: 进入spring:bind标签源码你可以看到 Object target = requestContext.getModelObject(beanNa ...
- Neither BindingResult nor plain target object for bean
当你开发一个项目,如果你选择的是spring MVC 框架,而你在前台使用spring的标签时,那么你有可能出现在这个情况. javax.servlet.jsp.JspTagException: Ne ...
- SpringMVC java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name
当跳转到一个含有form表单的页面的时候 如<form:form commandName="useCarInfo" 必须要new一个useCarInfo的同名实例给jsp来接 ...
- Neither BindingResult nor plain target object for bean name 'command' available as request attribute
最近用JSR303在表单提交时使用Java Bean Validation验证数据.报错堆栈如下: java.lang.IllegalStateException: Neither BindingRe ...
- 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 ...
- 当使用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
Neither BindingResult nor plain target object for bean name 'command' available as request attribute ...
- 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
随机推荐
- Android学习之Notification
Notification可以在手机的状态栏发出一则通知,它需要用NotificationManager来管理,实现Notification其实很简单. 1.通过getsystemservice方法获得 ...
- Android学习自定义Dialog
Dialog是Android提供的各种对话框的基类,和上篇的DialogFragment类似.为什么还要介绍Dialog呢,因为DialogFragment只能运行在Android3.0以上的系统中. ...
- Oracle 物理DG切换
在进行DATA GUARD的物理STANDBY切换前需要注意:确认主库和从库间网络连接通畅:确认没有活动的会话连接在数据库中:PRIMARY数据库处于打开的状态,STANDBY数据库处于MOUNT状态 ...
- android 后台运行
改写返回键事件监听,使得back键功能类似home键,让Acitivty退至后台时不被系统销毁,代码如下: public boolean onKeyDown(int keyCode, KeyEvent ...
- 《C++ Primer Plus 6th》读书笔记 - 第十章 对象和类
1. 过程性编程和面向对象编程 2. 抽象和类 1. 使用类对象的程序都可以直接访问公有部分,但只能通过公有成员函数(或友元函数)来访问对象的私有成员 2. 可以在类声明之外定义成员函数,并使其成为内 ...
- C# 封装 System.Data.SQLite
参考1: 关于如何使用System.Data.SQLite的入门: http://www.dreamincode.net/forums/topic/157830-using-sqlite-with-c ...
- Unix下C程序内存泄露检测工具:valgrind的安装使用
Valgrind是一款用于内存调试.内存泄漏检测以及性能分析的软件开发工具. Valgrind的最初作者是Julian Seward,他于2006年由于在开发Valgrind上的工作获得了第二届Goo ...
- 当tomcat有两个链接数据库的应用同时运行可能冲突
-Xms512M -Xmx1024M -XX:MaxPermSize=256M
- AJAX远程跨域获取数据
//本地获取json文件 $.ajax({ url : 'json.php', type : 'post', dataType : 'json',//返回json数据格式 success : func ...
- Delphi SysErrorMessage 函数和系统错误信息表
在看 API 文档时, 我们经常见到 GetLastError; 它可以返回操作后系统给的提示. 但 GetLastError 返回的只是一个信息代码, 如何返回对应的具体信息呢? FormatMes ...