我正在开发一个应用程序,我正在使用它向REST Web服务发送请求
@RequestMapping(value = "myURLpattern", method = RequestMethod.GET, produces = "image/png")
如果有人在URL查询字符串中输入#,我遇到了一个错误
http://myserver.com:8080/csg?x=1&y=2#4&z=32&p=1
所以我尝试通过过滤器HTTPRequestWrapper
对其进行编码,以便使用#
将%23
替换为URLEncoder
。
我的问题是编码网址,首先我需要阅读URL(request.getRequestURL())
。
并且getURL再次无法在#之后读取字符串。
request.getRequestURL()
只会返回(http://myserver.com:8080/csg?x=1&y=2)
在发送到REST Web服务之前,还有其他方法可以解析完整的URL并对其进行编码吗?
答案 0 :(得分:2)
这不是一个错误。检查一下:
What is the meaning of # in URL and how can i use that?
url查询字符串中的#是错误的。在将其发送到服务器之前,您应该在客户端对其进行编码。见这一个:How to pass '#' in query string 它在asp中,但你应该找到java等价物。