grails.rest.RestfulController。如何在 UrlMappings 中添加参数?
grails.rest.RestfulController. How to add a parameter in the UrlMappings?
如何在不覆盖更新的情况下在 UrlMappings 中添加参数?
"/hospitalReferral/admission/$id?"(controller:'hospitalReferral'){
action = [PUT:"update"]
admissionDate = new Date().format("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") //controller does not see this parameter
}
您可以从 url 映射传递任意参数。
取自 documentation (Arbitrary Variables) 的示例:
"/holiday/win" {
id = "Marrakech"
year = 2007
}
您可以使用 params
从控制器访问参数。
您可以传递数字或字符串,但不能传递对象。所以你需要将日期转换成字符串才能作为参数传递。
这适用于我的 Grails 2.4.2
"/hospitalReferral/admission/$id?"(controller: 'hospitalReferral', action: 'update', method: 'PUT') {
admissionDate = new Date().format("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
}
如何在不覆盖更新的情况下在 UrlMappings 中添加参数?
"/hospitalReferral/admission/$id?"(controller:'hospitalReferral'){
action = [PUT:"update"]
admissionDate = new Date().format("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") //controller does not see this parameter
}
您可以从 url 映射传递任意参数。
取自 documentation (Arbitrary Variables) 的示例:
"/holiday/win" {
id = "Marrakech"
year = 2007
}
您可以使用 params
从控制器访问参数。
您可以传递数字或字符串,但不能传递对象。所以你需要将日期转换成字符串才能作为参数传递。
这适用于我的 Grails 2.4.2
"/hospitalReferral/admission/$id?"(controller: 'hospitalReferral', action: 'update', method: 'PUT') {
admissionDate = new Date().format("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
}