In Grails, how can I get the request URI including

2019-03-30 21:57发布

If my incoming URL is this....

http://data-api:8080/policies/400?output=json

...what method on the request object in Grails will give me this...

/policies/400?output=json

I know request.forwardURI gives everything up to ?, but does not include the parameters

3条回答
小情绪 Triste *
2楼-- · 2019-03-30 22:23

I found the difference of request.requestURI between in Jetty and in WebLogic 10.2.

So, I use helper class :

def helper = new org.springframework.web.util.UrlPathHelper()
def reqURI = helper.getOriginatingRequestUri(request)
def qryStr = helper.getOriginatingQueryString(request)
查看更多
啃猪蹄的小仙女
3楼-- · 2019-03-30 22:26

it's maybe not the best solution, but I use the following:

request.forwardURI+'?'+request.'javax.servlet.forward.query_string'
查看更多
太酷不给撩
4楼-- · 2019-03-30 22:37
request.requestURI + '?' + request.queryString 
查看更多
登录 后发表回答