如何在Spring中的请求参数中发送特殊字符 [英] How to send special characters in request parameters in Spring

查看:1135
本文介绍了如何在Spring中的请求参数中发送特殊字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何处理请求参数中的特殊字符?这是我的控制器:

How to handle special characters in request parameters? Here is my controller:

@Scope("request")
@RestController
public class GetOperatorSeries{
@RequestMapping(value = "test", method = RequestMethod.GET)
    public String getOperatorSeries(HttpServletResponse response, @RequestParam(value = "mobno") long mobno,
            @RequestParam(value = "sourceType") String sourceType,
            @RequestParam(value = "responseType") String responseType)
{

}

例如,如果我在请求参数中使用任何特殊字符,那么它就不会读取它,就像我发送sourceType = @ $ abc那样它会将其读为null或空。但我希望它也应该读取特殊字符。

For example if I use any special characters in request param then it do not read it, like if I am sending "sourceType= @$abc" then it would read it as null or empty. But I want that it should read special characters also.

推荐答案

您需要对请求参数进行编码。

You need to encode your request params.

点击此链接查看列表: http ://www.w3schools.com/tags/ref_urlencode.asp

Check this link for a list : http://www.w3schools.com/tags/ref_urlencode.asp

这是来回转换: http://meyerweb.com/eric/tools/dencoder/

这篇关于如何在Spring中的请求参数中发送特殊字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆