grails的UrlMapping常用配置示例

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

class UrlMappings {
//grails框架不处理以下请求,也就是不经过grails的Controller,由web服务器处理
    static excludes = ["/static/*","/upload/*"]

    static mappings = {

        "/$controller/$action?/$id?"{
            constraints {
                // apply constraints here
            }
        }

	"/"(controller:"home")

        "500"(view:'/error')

        "404"(view:'/not_found')

        //注册页面
        "/register"(controller:"register")

        "/code/$username/$id"{
            controller = 'code'
            action = 'show'
            //参数约束
            constraints {
                id(matches:/\d+/)
            }
        }

        }


}