我有這樣一個Grails控制器動作.....沒有這樣的屬性:屬性ID類:grails.converters.JSON
控制器:Home.groovy
def search(){
def pl=Long.valueOf(params.pl).longValue(); println pl
def mil=Long.valueOf(params.mil).longValue(); println mil
def mal=Long.valueOf(params.mal).longValue(); println mal
def mic=Long.valueOf(params.mic).longValue(); println mic
def mac=Long.valueOf(params.mac).longValue(); println mac
def mib=Long.valueOf(params.mib).longValue(); println mib
def mab=Long.valueOf(params.mab).longValue(); println mab
Type pt=Type.valueOf(params.pt); println pt
def results=Project.executeQuery("""
select new map (prt.name as name,pp.id as propertyId,pp.constructedSize as constructedSize,
prt.propertyLocation.name as location,pp.mrp as mrp,pp.landSize as landSize,
pp.propertyType.name as propertyType)
from Project prt
JOIN prt.projectProperties pp where
pp.propertyType.name=:pt and
pp.constructedSize between :mic and :mac and
pp.landSize between :mil and :mal and
pp.mrp between :mib and :mab and
prt.propertyLocation.id=:pl
""",[mic:mic,mac:mac,mil:mil,mal:mal,mib:mib,mab:mab,pl:pl,pt:pt])
println results
def customerInstance=new Customer()
render (view:'search',model:[results:results as JSON,customerInstance:customerInstance])
}
和從此操作呈現的視圖僅在以下部分出現錯誤...
查看:Search.gsp
<table style="width: 50%;">
<g:each in="${results}" var="item">
<tr>
<td><div class="box shadow-outside-all" >
<input type="checkbox" name="getInterest" id="getInterest"
value="${item.propertyId}" style="float: left;" />
<b> ${item.name?.encodeAsHTML()}</b></br>
Property Type: ${item.propertyType?.encodeAsHTML()}</br>
Constructed Size:${item.constructedSize?.encodeAsHTML()}</br>
Land Size: ${item.landSize?.encodeAsHTML()}</br>
MRP: ${item.mrp?.encodeAsHTML()}</br>
Location: ${item.location?.encodeAsHTML()}</br>
</div>
</td>
</tr>
</g:each>
<br />
</table>
,誤差...
錯誤
No such property: propertyId for class: grails.converters.JSON. Stacktrace follows:
org.codehaus.groovy.grails.web.pages.exceptions.GroovyPagesException: Error evaluating expression [item.propertyId] on line [144]: No such property: propertyId for class: grails.converters.JSON
at E__Yogesh_development_work_client_okruti_propertyHub_grails_app_views_home_search_gsp$_run_closure2.doCall(search.gsp:144)
at E__Yogesh_development_work_client_okruti_propertyHub_grails_app_views_home_search_gsp.run(search.gsp:216)
at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:200)
at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)
at grails.plugin.springsecurity.web.filter.GrailsAnonymousAuthenticationFilter.doFilter(GrailsAnonymousAuthenticationFilter.java:53)
at grails.plugin.springsecurity.web.authentication.RequestHolderAuthenticationFilter.doFilter(RequestHolderAuthenticationFilter.java:49)
at grails.plugin.springsecurity.web.authentication.logout.MutableLogoutFilter.doFilter(MutableLogoutFilter.java:82)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
Caused by: groovy.lang.MissingPropertyException: No such property: propertyId for class: grails.converters.JSON
at E__Yogesh_development_work_client_okruti_propertyHub_grails_app_views_home_search_gsp$_run_closure2_closure21.doCall(search.gsp:144)
... 10 more
任何幫助,將不勝感激.....
你爲什麼你的渲染結果JSON這樣呢?不要將它們呈現爲JSON。您的GSP期望地圖/模型不是JSON結果。 –
thinks @JoshuaMoore你的主意工作 –
爲什麼@Dónal我知道也許它是一個愚蠢的問題,但我是一個初學者很抱歉 –