开发者

Grails: URL mapping - how to pass file extension?

开发者 https://www.devze.com 2022-12-25 09:51 出处:网络
I have some folder with different files. I want to use something like this: http://myserver.com/foo/bar/test.html

I have some folder with different files. I want to use something like this: http://myserver.com/foo/bar/test.html

I'm using this way to obtain path:

"/excursion/$path**" (controller:"excursion", action:"sweet")  

But it doesn't helps with file extensions... How to disable file extensions truncating ?

P.S.

class ExcursionController {
 def 开发者_如何学运维defaultAction = "sweet"

 def sweet = {
  render "${params.path}"
 }
}

Request http://myserver.com/excursion/foo/bar/test.html

The result is "foo/bar/test" with no extension :(


what does

render "${params.path}.${request.format}"

give you?


Disable file extension truncation by adding this line to grails-app/conf/Config.groovy:

grails.mime.file.extensions = false

This impacts content negotiation, so I suggest you read section 7.8 of the Grails user guide

0

精彩评论

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