【问题标题】:Spring Rest service getting encoded request parameterSpring Rest服务获取编码的请求参数
【发布时间】:2023-04-05 01:59:02
【问题描述】:

我遇到了一个问题,即发送到 spring rest 服务的 URL 包含参数“xyz=abc & amp ;emailDate=2014-09-09”

此 URL 来自发送给客户的电子邮件。当客户点击 URL 时,用户手机上的某些浏览器客户端不会转换“&”到&。

请忽略上面的空格。 Stackoverflow 正在转换 & amp;到 & 如果没有空格。

当请求到达服务器时,我们看到 emailDate 为空。服务器端代码如下。

@RequestMapping(value="/openEmail", method=RequestMethod.GET)
public @ResponseBody byte[] openEmail(RequestParam(value="token",  required=false) String customerToken, @RequestParam(value="emailDate", required=false) String emailDate, HttpServletRequest request) throws IOException{

你能帮我解决这个问题吗?

【问题讨论】:

    标签: spring rest spring-mvc encoding escaping


    【解决方案1】:

    请检查您是否在 server.xml 中设置了 URIEncoding="UTF-8" (如果它的 tomcat )。更多细节在这里Get Parameter Encoding

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-11-18
      • 1970-01-01
      • 1970-01-01
      • 2014-12-14
      • 2016-01-17
      • 2020-04-03
      • 2018-05-30
      相关资源
      最近更新 更多