开发者

Grails URL Mapping question

I'm using Grails 1.2.1. I want to set up this mapping ...

http://localhost:8080/context-path/mediaproxy

So I added this to my URLMappings.groovy file ...

class UrlMappings {
    static mappings = {
      ‰name mediaproxy: "/mediaproxy" {
          controller = "SocialMediaCacheProxy"
          action = "index"
      }
      "/"(view:"/index")
      "500"(view:'/error')
    }

}

However, I'm getting a 404 when I visit the above URL. Here is how I set开发者_运维百科 up my controller

class SocialMediaCacheProxyController {

    def index = {
        if (params.dumpAll != null) {

        } else if (params.url != null) {
            doCacheTransport(params, response); 
        }   // if
    }

...
}

Any ideas what I'm doing wrong? Thanks, - Dave


There are is some weird character in front of your named mapping (‰) and your controller name should be lowercase on the first character so that it points to SocialMediaCacheProxyController.

If you don't need a named mapping the following mapping would do the trick for you:

class UrlMappings {
    static mappings = {
        "/mediaproxy"(controller:"socialMediaCacheProxy", action:"index")
        "/"(view:"/index")
        "500"(view:'/error')
    }
}


It might be some problem with your question formatting but I would expect the url mapping to look like this:

class UrlMappings {
    static mappings = {
      "/mediaproxy" {
          controller = "SocialMediaCacheProxy"
          action = "index"
      }
      "/"(view:"/index")
      "500"(view:'/error')
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜