0

我有一个像这样的网址:

/test/abs/rdc/tx.js

我需要能够为我的控制器获取 /abs/rdc/tx.js 部分。

我试过(在 URLMapping 中):

/test/$target**

它返回除 .js 之外的所有内容

我有

grails.mime.file.extensions = true 

有任何想法吗?

UrlMapping 和文件扩展名不起作用,因为它总是返回 .html

4

2 回答 2

3

Grails 2.0 对解析格式的方式进行了一些更改。使用您提供的链接中的示例,只需更新要使用的代码response.format

def path = params.path
if (!FilenameUtils.getExtension(path) && response.format) {
  path += ".${response.format}"
}

更多信息在Content Negotiation下的手册中。向下滚动到标题为请求格式与响应格式的部分。

于 2012-02-14T21:30:11.963 回答
0

你可以试试这个:

//Grails 2.3.x
"/$controller/$action?/$id?(.${format})?"{
    constraints {
        // apply constraints here
    }
}
于 2015-05-27T11:49:23.427 回答