问题描述:

页面使用标签<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的更多相关文章

  1. javax.servlet.jsp.JspTagException: Neither BindingResult nor plain target object for bean (蛋疼死我了)

    1为抛出异常原因,2为异常解决方法. 原因:   进入spring:bind标签源码你可以看到 Object target = requestContext.getModelObject(beanNa ...

  2. Neither BindingResult nor plain target object for bean

    当你开发一个项目,如果你选择的是spring MVC 框架,而你在前台使用spring的标签时,那么你有可能出现在这个情况. javax.servlet.jsp.JspTagException: Ne ...

  3. SpringMVC java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name

    当跳转到一个含有form表单的页面的时候 如<form:form commandName="useCarInfo" 必须要new一个useCarInfo的同名实例给jsp来接 ...

  4. Neither BindingResult nor plain target object for bean name 'command' available as request attribute

    最近用JSR303在表单提交时使用Java Bean Validation验证数据.报错堆栈如下: java.lang.IllegalStateException: Neither BindingRe ...

  5. 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 ...

  6. 当使用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 ...

  7. 异常: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 ...

  8. Neither BindingResult nor plain target object for bean name 'user' available as request attribute

    这个异常是因为jsp页面写错了. 把<form:form></form:form>标签改成普通的标签即可. 应该是第一次访问的时候,user是空的.但springmvc不能是空 ...

  9. java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'user'

    转自: https://blog.csdn.net/Winter_chen001/article/details/77332944

随机推荐

  1. Android长方形图片生成正圆形,以及矩形图片生成圆角

    一般要做正圆形图片,只能是正方形的基础上才能实现,否则就变成椭圆了,下面说说如何使长方形的图片生成正圆形图片 废话不多说,没图没真相,先上图吧: 原图:  变成正圆后:  下面上代码: public ...

  2. 在 Mac OS X Lion 下修改 Hosts 的四种方法

    一名刚刚使用 Mac OS X Lion 系统的朋友问我怎么该系统下修改 Hosts 文件,说网上搜了很多办法都不管用,只要编辑 Hosts 文件就出现”你不是文件 hosts 的所有者,因此没有权限 ...

  3. GetBuffer与ReleaseBuffer的用法,CString剖析

    转载: http://blog.pfan.cn/xman/43212.html GetBuffer()主要作用是将字符串的缓冲区长度锁定,releaseBuffer则是解除锁定,使得CString对象 ...

  4. UVA 10410 Tree Reconstruction

    题意: 给定一个树的BFS和DFS,求这棵树. 分析: 拿dfs的序列,分成若干段,每一段相当一个子树,这样就可以利用bfs的序列去将dfs的序列分段,然后利用一个队列去存放每一段,不断求出子树即可. ...

  5. ImageButton与Button

    1.Button控件 Butotn控件,主要用来实现一些命令操作,通过注册监听事件来实现.首先需要在xml文档中放入一个button按钮. <Button android:id="@+ ...

  6. Kurskal算法(克鲁斯卡尔算法)

    特点:适用于稀疏图,边比较少的图.如果顶点较少,且为稠密图,则用Prim算法.跟Prim算法的用途相同.时间复杂度为O(e*loge),其中e为边数. 代码: #include <stdio.h ...

  7. Lucene学习之CURD

    创建索引 Lucene在进行创建索引时,根据前面一篇博客,已经讲完了大体的流程,这里再简单说下: Directory directory = FSDirectory.open("/tmp/t ...

  8. Spring XML 不给提示

    a)window – preferences – myeclipse – xml – xml catalog b)User Specified Entries – add i. Location: D ...

  9. php-mysql 问题笔记一——在命令行中可以执行的sql语句,无法从php页面页面执行!

    我的情况: 1.由于外键较多,插入数据时,提前关闭外键(SET FOREIGN_KEY_CHECKS=0). 2.所使用的sql语句中,有外键绑定到其他表中,所以无法从php页面插入. 原因分析: S ...

  10. Struts2命名空间问题

    警告: No configuration found for the specified action: '/myNameSpace/login.action' in names 今天花了点时间把st ...