Grails: URL mapping - how to pass file extension?

笑着哭i 提交于 2019-12-24 10:53:42

问题


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 :(


回答1:


what does

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

give you?




回答2:


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



来源:https://stackoverflow.com/questions/2552215/grails-url-mapping-how-to-pass-file-extension

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!