简体   繁体   English

Spring Rest服务获取编码的请求参数

[英]Spring Rest service getting encoded request parameter

I am facing an issue where url sent to spring rest service containing parameter "xyz=abc & amp ;emailDate=2014-09-09" 我面临的问题是,发送到包含参数“ xyz = abc& emailDate = 2014-09-09”的spring rest服务的URL

This URL is hit from emails sent to the customer. 该URL是从发送给客户的电子邮件中命中的。 And when customer hits the URL some browser client on user's mobile is not converting "& amp ;" 当客户点击URL时,用户移动设备上的某些浏览器客户端不会转换“&” to &. 至 &。

Please ignore spaces above. 请忽略上面的空格。 Stackoverflow is converting & amp ; Stackoverflow正在转换和放大; to & if there are no spaces. 到&,如果没有空格。

When request comes to server we see emailDate as null. 当请求到达服务器时,我们将emailDate视为null。 Server side code is as below. 服务器端代码如下。

@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{

Can you please help me overcome this issue. 您能帮我解决这个问题吗?

Please check if you set URIEncoding="UTF-8" in your server.xml ( if its tomcat ). 请检查是否在server.xml中设置了URIEncoding =“ UTF-8”(如果它是tomcat的话)。 More details here Get Parameter Encoding 在此处获取更多详细信息获取参数编码

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

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