Grails 可以处理 URL 中编码的斜杠吗?
我有一个 Grails 应用程序,我想在 URL 中放置一个包含轮胎尺寸信息的参数。轮胎尺寸信息如下所示:“225/60R18 104Y”。斜杠不是路径分隔符,幸运的是,Grails 足够聪明,可以将其编码为 /foo/225%2F60R18+104Y。然而,实际上调用这个 URL 是行不通的。我得到一个空白页,没有错误或任何东西。将 %2F 转换为斜杠会给我一个错误页面(预期),而将其省略可以让我找到正确的控制器和操作,但尺寸信息错误。
那么这里有什么问题呢?为什么 Grails 不能处理这个问题,有什么办法可以解决这个问题吗?
更新: 看来 Apache 和 Tomcat 都是罪魁祸首。也许可以通过添加AllowEncodedSlashes NoDecode 来使Apache 正常工作,但现在我必须弄清楚如何让Tomcat 接受这一点。
I've got a Grails app, and I want to put a parameter containing tire size info in the URL. Tire size info looks like: "225/60R18 104Y". The slash is not a path separator, and fortunately, Grails is smart enough to encode it to /foo/225%2F60R18+104Y. Actually calling this URL doesn't work, however. I get a blank page, no error or anything. Turning the %2F into a slash gives me an error page (expected), and leaving it out gets me to the correct controller and action, but with the wrong size info.
So what's the problem here? Why can't Grails deal with this, and is there any way to fix that?
Update: Looks like both Apache and probably Tomcat are the culprits here. Apache can probably be made to behave by adding AllowEncodedSlashes NoDecode
, but now I have to figure out how to get Tomcat to accept this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 URL 映射中的参数后面添加
**
对我有用。例如,将
'/foo/$tire'
更改为'/foo/$tire**'
Adding
**
after parameter in URL Mapping worked for me.For example, change
'/foo/$tire'
to'/foo/$tire**'
假设您将轮胎尺寸读取为
params.id
,您可以使用 Grails 编解码器:此致,
德銮
Assuming you're reading tire size as
params.id
, you can use Grails codecs:Regards,
Deluan