一般是由于参数类型不正确所致。比如表单如下:
<form:form action="" method="post" commandName="shop"><form:hidden path="id"/><form:input type="text" path="shopName" /><input type="submit" value="保存" /></form:form>
实体类如下:
public class ShopEntity {private ObjectId id;private String shopName;
}
当<form:hidden path="id"/>
的值为空时,就会引发该错误,因为该表单项对应的值不是基本类型,而是一个ObjectId类型,null无法转成该类型。
改正办法:添加一个判断,只有id存在时才加载隐藏控件
<c:if test="${shop.id!=null}"><form:hidden path="id"/></c:if>