Grails URL映射和URL中的斜杠字符 [英] Grails URL Mapping and slash character in URL
问题描述
我的Grails(2.2.0)应用程序具有以下URL映射:
/ api / clientQuote / $ labcode / $ cliCode / $ quoCode(controller:clientQuote){
action = [GET:get]
}
假设以下值:
$ labcode = BRMIN
$ cliCode = CL-000236
$ quoCode = QT-000965 / 0-0
由于$ quoCode具有斜杠字符,因此需要将其替换为%2F。这样,一个可能的网址可能是:
http://myapp.com:9090/CCLASService/api/clientQuote/BRMIN/CL-000236/QT-000965%2F0-0
当我在任何浏览器中放置此URL时,会显示一个空白屏幕作为返回。这很奇怪,因为请求甚至不能到达我的Grails控制器。
另一方面,如果我更改以下网址:
一切工作正常,我收到了正确的XML响应我的请求。
问题是:为什么当我使用特定的URL映射与编码字符我收到一个空白屏幕作为回报?
URL映射可以使用 $ paramName **
一个特定的参数 - 这通常用于类似于CMS的地方,您希望将整个虚拟路径层次结构映射到单个控制器,但它也可能对您的情况有用。
/ api / clientQuote / $ labcode / $ cliCode / $ quoCode **(controller:clientQuote){
action = [GET:get]
}
这将允许 http://myapp.com :9090 / CCLASService / api / clientQuote / BRMIN / CL-000236 / QT-000965 / 0-0
即使没有斜线逃脱。
I'm facing the following problem:
My Grails (2.2.0) app has the following URL Mapping:
"/api/clientQuote/$labcode/$cliCode/$quoCode"(controller: "clientQuote") {
action = [GET: "get"]
}
Let's suppose the following values:
$labcode = BRMIN
$cliCode = CL-000236
$quoCode = QT-000965/0-0
Since $quoCode has a slash character, it's necessary to replace it for %2F. This way, a possible URL could be:
http://myapp.com:9090/CCLASService/api/clientQuote/BRMIN/CL-000236/QT-000965%2F0-0
When I put this URL in any browser a blank screen is showed as return. It's strange because the request doesn't even reach my Grails controller.
For other side, if I change the url for:
Everything works fine, I receive a correct XML response to my request.
The question is: Why when I use a specific URL Mapping with a encoded character I receive a blank screen as return?
URL mappings can use $paramName**
to allow slashes within a particular parameter - this is typically used with something like a CMS where you want to map a whole virtual path hierarchy to a single controller, but it could be useful in your case too.
"/api/clientQuote/$labcode/$cliCode/$quoCode**"(controller: "clientQuote") {
action = [GET: "get"]
}
This would permit http://myapp.com:9090/CCLASService/api/clientQuote/BRMIN/CL-000236/QT-000965/0-0
even without the slash escaped.
这篇关于Grails URL映射和URL中的斜杠字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!