Grails - 禁用默认 url 映射
Grails - Disable default url mappings
我想禁用 grails 的默认 url 映射。我从 UrlMappings.groovy 文件中删除了所有映射。它完全是空的。但是当我 运行 url-mappings-report 命令时,我仍然看到默认映射为
Dynamic Mappings
| * | ERROR: 404 | View: /notFound |
| * | ERROR: 500 | View: /error |
| * | / | View: /index |
| * | /${controller}/${action}?/${id}?(.${format)? | Action: (default action) |
删除 UrlMappings.groovy 文件中的所有映射后,我预计会收到 404 not found 或错误,但由于我们看到的最后一个映射,它可以正常工作。我怎样才能摆脱这些默认映射?
在没有看到您的项目的情况下,很难说出该映射的来源。您可能正在使用提供该映射的插件。
在 https://github.com/jeffbrown/alituranurls 查看项目。
https://github.com/jeffbrown/alituranurls/blob/master/grails-app/controllers/alituranurls/UrlMappings.groovy 只包含 404 映射:
package alituranurls
class UrlMappings {
static mappings = {
"404"(view:'/notFound')
}
}
URL映射报告符合:
$ ./grailsw url-mappings-report
| * | ERROR: 404 | View: /notFound |
我想禁用 grails 的默认 url 映射。我从 UrlMappings.groovy 文件中删除了所有映射。它完全是空的。但是当我 运行 url-mappings-report 命令时,我仍然看到默认映射为
Dynamic Mappings
| * | ERROR: 404 | View: /notFound |
| * | ERROR: 500 | View: /error |
| * | / | View: /index |
| * | /${controller}/${action}?/${id}?(.${format)? | Action: (default action) |
删除 UrlMappings.groovy 文件中的所有映射后,我预计会收到 404 not found 或错误,但由于我们看到的最后一个映射,它可以正常工作。我怎样才能摆脱这些默认映射?
在没有看到您的项目的情况下,很难说出该映射的来源。您可能正在使用提供该映射的插件。
在 https://github.com/jeffbrown/alituranurls 查看项目。
https://github.com/jeffbrown/alituranurls/blob/master/grails-app/controllers/alituranurls/UrlMappings.groovy 只包含 404 映射:
package alituranurls
class UrlMappings {
static mappings = {
"404"(view:'/notFound')
}
}
URL映射报告符合:
$ ./grailsw url-mappings-report
| * | ERROR: 404 | View: /notFound |