UrlMapping Weirdness (again)

4 views
Skip to first unread message

Robert Fischer

unread,
May 14, 2008, 10:11:20 AM5/14/08
to groo...@googlegroups.com
So, here's my Urlmappings file.

class UrlMappings {
static mappings = {
"/" (controller: "login", action: "index")

"/search" (controller: "caseSearch", action: "index")

"/${id}.xml" {
controller = 'xmlMncis'
action = 'index'
}

"/$controller/id/$id" {
action = 'index'
}

"/$controller/$action?/$id?" {
}

"500"(view: '/error')
}
}


But, when I go to /app/1234.xml, this is what I get:


[94945] filter.UrlMappingsFilter Executing URL mapping filter...
[94945] filter.UrlMappingsFilter URL Mappings
------------
org.codehaus.groovy.grails.web.mapping.ResponseCodeUrlMapping@9b5cd2
/(*).xml
/search
/
/(*)/id/(*)
/(*)/(*)?/(*)?

[94946] mapping.DefaultUrlMappingsHolder Attempting to match URI [/1234] with pattern [500]
[94946] mapping.DefaultUrlMappingsHolder Attempting to match URI [/1234] with pattern [/(*).xml]
[94946] mapping.DefaultUrlMappingsHolder Attempting to match URI [/1234] with pattern [/search]
[94946] mapping.DefaultUrlMappingsHolder Attempting to match URI [/1234] with pattern [/]
[94946] mapping.DefaultUrlMappingsHolder Attempting to match URI [/1234] with pattern [/(*)/id/(*)]
[94946] mapping.DefaultUrlMappingsHolder Attempting to match URI [/1234] with pattern [/(*)/(*)?/(*)?]
[94956] mapping.DefaultUrlMappingsHolder Matched URI [/1234] with pattern [/(*)/(*)?/(*)?], adding
to posibilities

So, it's stripping off the file type. How do I get access to the file type from my controller, and
how do I get it to respect that style of URL?

~~ Robert.

Justin Grammens

unread,
May 15, 2008, 10:38:25 PM5/15/08
to groo...@googlegroups.com
Hi Robert,

Might this thread be related to your issue?

http://www.nabble.com/Bug--UrlMappings-param-containing-dot-%22.%22-in-URL-get-chopped-td16346107.html

I don't have any solutions for you, other than to say that I've run into a similar situation for content negotiation. On a project earlier this year I had a RESTful controller in which I was trying to send back different content-type based on the extension. ie. .xml (returns XML), .json (returns json), etc.
I don't recall the specifics, but I had a heck of a time fiddling around with trying to get it to work and instead just resorted to using ?format=xml and ?format=json, etc. as the only way to specify the return type. As I said, this was earlier this year and maybe in a more recent release this has been fixed, but I was pretty surprised that specifying the content type as an extension wasn't working out of the box.

Justin

Robert Fischer

unread,
May 16, 2008, 8:57:17 AM5/16/08
to groo...@googlegroups.com
I haven't tried it, but the user list said that I could get at the filename extensions by turning
off content negotiation. The magic chant is "grails.mime.file.extensions = false"

I'll let you know how that goes for me.

~~ Robert.

Reply all
Reply to author
Forward
0 new messages