最近学习springmvc的表单标签库,其中form标签主要用于渲染HTML表单,而form标签有很多属性,可供选择,其中一般来说(以前)最重要的是commandName属性,因为它定义了模型属性的名称,包含了一个backing object,其属性是用来填充说生成的表单的内容的。同时,使用此属性要求在后台的请求处理方法中添加相应的模型属性进行返回,这样commandName才能生效,简单代码如下:

 <form:form action="/book_save" method="post" commandName="book">

  

        model.addAttribute("book", new Book());

  最终的结果如题所示:Unable to find setter method for attribute: [commandName]。

解释下原因:

  学习的内容较旧了,贴出spring-form.tld中的一点东西

		<attribute>
<description>DEPRECATED: Use "modelAttribute" instead.</description>
<name>commandName</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>

  这个属性其实已经过时了,现在应该使用modelAttribute属性,使用方法相同。

解决Unable to find setter method for attribute: [commandName]的更多相关文章

  1. Java报错:Unable to find setter method for attribute: [x]

    在学习JavaWeb JSTL与自定义标签时遇到的坑,用的老师给的代码结果直接原地报错:javax.servlet.ServletException: org.apache.jasper.Jasper ...

  2. Unable to find setter method for attribute: 属性名

    tld文件里面的名称和标签内的属性名要一致.

  3. 自定义标签 Unable to find setter method for attribute

    变量的首字母不能大写 http://blog.csdn.net/looksun/article/details/7690601

  4. is not writable or has an invalid setter method错误的解决

    java中在配置spring时,遇到is not writable or has an invalid setter method的错误一般是命名方式的问题 需要写成private userInfoD ...

  5. ERROR: HHH000123: IllegalArgumentException in class: com.tt.hibernate.helloworld.News, setter method of property: date

    问题描述: Hibernate连接数据库时,报出如下错误: 十一月 29, 2016 3:08:31 下午 org.hibernate.tool.hbm2ddl.SchemaUpdate execut ...

  6. 错误:Bean property 'sessionFactory' is not writable or has an invalid setter method.

    Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'sessionFactory' ...

  7. Log4j2 - Unable to invoke factory method in class org.apache.logging.log4j.core.appender.RollingFileAppender for element RollingFileAppender for element RollingFile

    问题与分析 在使用Log4j2时,虽然可以正确读取配置文件并生成log文件,但偶然发现控制台打印了异常信息如下: 2018-12-31 17:28:14,282 Log4j2-TF-19-Config ...

  8. Android Unable to execute dex: method ID not in [0, 0xffff]: 65536 问题解决方法

    开始一个新项目的时候,Build工程的时候一直报这个错误: 控制台报错误:Conversion to Dalvik format failed: Unable to execute dex: meth ...

  9. org.springframework.beans.NotWritablePropertyException:Bean property 'xxxService' is not writable or has an invalid setter method.

    完整报错提示信息:Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'blogDe ...

随机推荐

  1. 浅谈字体小图标font awesome,iconfont,svg各自优缺点

    三种都是矢量图(即放大不失真),但是个自又有个自的优缺点, 1.font awesome: 优点:相对比较简单,查看官网看例子基本上都会用 (http://www.bootcss.com/p/font ...

  2. IntelliJ配置jenkins服务的Crumb Data

    近期在做jenkins测试,IntelliJ并没有自动安装jenkins服务器,因此需要自己添加,但是如果不配置Crumb Data,jenkins的服务就不能使用. 首先在服务器中开启CSRF服务, ...

  3. Docker(社区版) centos版 安装

    1,总结一下docker的安装,其实官网有很全面的资料了,可以自己上面去看,但都是英文的. https://docs.docker.com/engine/installation/linux/dock ...

  4. Java中static关键字的详解

    static关键字可以修饰方法和成员变量(不可以修饰局部变量,但是可以修饰内部类). static关键字方便在没有创建对象的情况下来进行调用(方法/变量). 很显然,被static关键字修饰的方法或者 ...

  5. YII2 models非常好用的控制输出数据【重写Fields】

    models里重写Fields真的很好用,用于分类.评论功能 列子:评论表models/Comment.php 1.关联商品表 2.获取父级(即管理员)评论 public function Field ...

  6. ssh简单配置

    Port 2223Protocol 2HostKey /etc/ssh/ssh_host_rsa_keyHostKey /etc/ssh/ssh_host_dsa_keyKeyRegeneration ...

  7. Python 集合整理

  8. SQL语言(一)

    设计表student如下

  9. Oracle存储过程和自定义函数

    新博客文章链接,欢迎大家评论探讨 概述 存储过程和存储函数是指存储在数据库中供所有用户程序调用的子程序叫存储过程.存储函数. 异同点: 存储过程和存储函数的相同点:完成特定功能的程序. 存储过程和存储 ...

  10. 实验:企业级分布式存储应用与实战-mogilefs实现

    实验:企业级分布式存储应用与实战-mogilefs实现 (1)安装mogilefs 1.创建一个存放安装mogilefs所需的软件包的目录 cd /app/ mkdir mogilefs cd mog ...