我正在尝试使用字段插件修改字段脚手架代码。我也安装了 twitter 引导程序。现在我想在一行中显示 2 个字段。我在 _form.gsp 模板文件中执行了以下操作:
private renderFieldForProperty(p, owningClass,counter, prefix = "") {
boolean hasHibernate = pluginManager?.hasGrailsPlugin('hibernate')
boolean display = true
boolean required = false
if (hasHibernate) {
cp = owningClass.constrainedProperties[p.name]
display = (cp ? cp.display : true)
required = (cp ? !(cp.propertyType in [boolean, Boolean]) && !cp.nullable && (cp.propertyType != String || !cp.blank) : false)
}
if (display) {
if(counter%2==0){
%><div class="row-fluid"><%
}
%>
<f:field bean="${domainClass.propertyName}" property="${p.name}"/>
<%
counter++
if(counter%2==0){
%></div><%
}
} } %>
现在生成的代码如下:
<div class="row-fluid">
<f:field bean="patient" property="familyName"/>
<f:field bean="patient" property="firstName"/>
</div>
当我尝试在浏览器中查看代码时,出现此异常:
URI
/patient/create
Class
org.springframework.beans.NotReadablePropertyException
Message
Invalid property 'familyName' of bean class [java.lang.String]: Bean property 'familyName' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
我想我做错了什么,对吗?我怎么能解决这个问题?
谢谢, 费拉斯