Search code examples
grails

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 ?


Solution

  • 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        |