简体   繁体   English

url 与 spring rest ful Z8A5DA52ED12644217D359E70C07A?

[英]encode url with spring rest ful api?

I have an api write by spring restful.我有一个 spring 写的 api 宁静。 And I test with postman I call this api with param: content: 60 days` .我用 postman 测试我称之为 api 参数:内容:60天`。

And when I catch it in backend through function below:当我通过下面的 function 在后端捕获它时:

Result<List<T>> search(HttpServletRequest request, HttpServletResponse response,@RequestParam(name="search") String search) {
    Map<String, String[]> params = request.getParameterMap();
    return getService().resolve(params);
}

the value of param content is:参数内容的值为: 在此处输入图像描述

How can I fix it?我该如何解决? Update:更新: 这个得到

在此处输入图像描述

The ' after days is a Unicode Character 'RIGHT SINGLE QUOTATION MARK' (U+2019) . ' daysUnicode 字符 'RIGHT SINGLE QUOTATION MARK' (U+2019)

In UTF-8, that character is encoded as bytes E2 80 99 .在 UTF-8 中,该字符被编码为字节E2 80 99

In ISO-8859-1, those bytes is â and two unprintable characters.在 ISO-8859-1 中,这些字节是â和两个不可打印的字符。

Conclusion: Postman is sending the content as UTF-8, but the server is reading it as ISO-8859-1.结论: Postman 将内容作为 UTF-8 发送,但服务器将其读取为 ISO-8859-1。

Now you could try to find out why that discrepancy exists, but did you really intend to have that "Right Single Quotation Mark" in your content?现在您可以尝试找出存在这种差异的原因,但您真的打算在您的内容中使用“右单引号”吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM