this follows the pattern I see in the Grails docs but yields the following error:
MissingPropertyException: No such property: json for class: java.lang.String
this follows the pattern I see in the Grails docs but yields the following error:
MissingPropertyException: No such property: json for class: java.lang.String
class UrlMappings { | |
static mappings = { | |
// REST - why not working?? | |
"/$controller/$id.json" { | |
action = [GET: 'show', PUT: 'update', DELETE: 'delete'] | |
} | |
"/$controller.json" { | |
action = [GET: 'list', POST: 'create'] | |
} | |
"/$controller/$action?/$id?"{ | |
constraints { | |
// apply constraints here | |
} | |
} | |
"/"(view:"/index") | |
"500"(view:'/error') | |
} | |
} |
its because
"/$controller.json"
is trying to access a propertyjson
oncontroller
, which is a string. In Groovy, you can go 1 property deep with string interpolation. Try"/${controller}.json"
.