参数值包含“.”的 Grails UrlMappings
给定此 UrlMapping:
"/foo/$foobar" {
controller = "foo"
action = "foo"
constraints {
}
}
与此控制器相结合:
class FooController {
def foo = {
def foobar = params.foobar
println "foobar=" + foobar
}
}
以及这些请求:
- http://localhost:8080/ app/foo/example.com 给出输出“foobar=example”
- http://localhost :8080/app/foo/examplecom 给出输出“foobar=examplecom”
看起来 Grails 在第一个点(“.”)处剪切了“foobar”参数。 这是故意的吗? 如果我想在 URL 映射中使用包含点的参数,是否有解决方法?
Given this UrlMapping:
"/foo/$foobar" {
controller = "foo"
action = "foo"
constraints {
}
}
Combined with this controller:
class FooController {
def foo = {
def foobar = params.foobar
println "foobar=" + foobar
}
}
And with these requests:
- http://localhost:8080/app/foo/example.com give the output "foobar=example"
- http://localhost:8080/app/foo/examplecom give the output "foobar=examplecom"
It seems like Grails cuts the "foobar" parameter at the first dot ("."). Is this intentional? Is there a work-around if I want to use parameters containing dots in my URL mappings?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
设置……来解决
这可以通过在Config.groovy中
。 看起来 Grails 正在尝试根据文件名后缀在幕后执行一些 MIME 魔法。
更新:来自 Grails JIRA 的一些附加信息。
这是 UrlMappingsFilter.java 中的违规代码:
WebUtils.areFileExtensionsEnabled() 返回 Config.groovy 中配置的“grails.mime.file.extensions”设置的值。
This can be solved by setting ...
... in Config.groovy.
It seems like Grails is trying to do some MIME magic behind the scene based on the file name suffix.
Updated: Some additional info from the Grails JIRA.
This is the offending code in UrlMappingsFilter.java:
WebUtils.areFileExtensionsEnabled() returns the value of the "grails.mime.file.extensions" setting configured in Config.groovy.