我正在尝试保存图片并返回它的visit-url,但系统抛出一个关于params的例外:'无法设置readonly属性:params'
def upload() {
def attachmentInstance = new Attachment(utype:params.type, udata:params.data)
if (!attachmentInstance.save(flush: true)) {
render(view: "create", model: [attachmentInstance: attachmentInstance])
return
}
def subMap = [url:"${createLink(controller:'attachment', action:'renderImg', params:'[id:${attachmentInstance.id}]')}", width:0, height:0]
def jsonMap = [id:attachmentInstance.id, type:"image", thumbnail:"", data:subMap]
def result = [result:jsonMap]
render result as JSON
}
答案 0 :(得分:1)
看起来有点过于复杂,你可以尝试一下:
def subMap = [url:createLink(controller:'attachment', action:'renderImg', params:[id:attachmentInstance.id]), width:0, height:0]