简体   繁体   中英

Grails - Disable default url mappings

I want to disable default url mappings of grails. I removed all mappings from UrlMappings.groovy file. It is completely empty. But when I run url-mappings-report command, I still see default mappings as

Dynamic Mappings
 |    *     | ERROR: 404                                        | View:   /notFound        |
 |    *     | ERROR: 500                                        | View:   /error           |
 |    *     | /                                                 | View:   /index           |
 |    *     | /${controller}/${action}?/${id}?(.${format)?      | Action: (default action) |

After deleting all mappings in UrlMappings.groovy file, I expect to get 404 not found or an error but It works because of the last mapping we see. How can I get rid of these default mappings ?

Without seeing your project it is difficult to say where that mapping is coming from. It is possible you are using a plugin that provides that mapping.

See the project at https://github.com/jeffbrown/alituranurls .

https://github.com/jeffbrown/alituranurls/blob/master/grails-app/controllers/alituranurls/UrlMappings.groovy contains nothing but the 404 mapping:

package alituranurls

class UrlMappings {

    static mappings = {
        "404"(view:'/notFound')
    }
}

The URL mapping report is consistent with that:

$ ./grailsw url-mappings-report
 |    *     | ERROR: 404      | View:   /notFound        |

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM