In Grails, how can I get the request URI including request parameters?

▼魔方 西西 提交于 2019-12-21 05:45:14

问题


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


回答1:


request.requestURI + '?' + request.queryString 



回答2:


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:


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

request.forwardURI+'?'+request.'javax.servlet.forward.query_string'


来源:https://stackoverflow.com/questions/8605885/in-grails-how-can-i-get-the-request-uri-including-request-parameters

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!