Gre*_*egg 5 grails url-mapping
我有以下内容:
"/api/users"(controller: "user") {
action = [GET:"list"]
}
Run Code Online (Sandbox Code Playgroud)
打电话给http://localhost:8080/platform/users
我得到一个用户列表.然后我添加了这个:
"/api/users"(controller: "user") {
action = [POST:"save"]
}
Run Code Online (Sandbox Code Playgroud)
现在我得到一个404,它没有击中UserController中的任何一个方法.我希望能够使用相同的URL和动词控制哪个动作.我做错了还是Grails不支持这个?
Jam*_*eeh 11
从Grails docs:URL Mappings
static mappings = {
"/product/$id"(controller:"product") {
action = [GET:"show", PUT:"update", DELETE:"delete", POST:"save"]
}
}
Run Code Online (Sandbox Code Playgroud)
对于你的情况:
"/api/users"(controller: "user") {
action = [GET:"list",POST:"save"]
}
Run Code Online (Sandbox Code Playgroud)