Java 在Spring中通过@RequestParam发送%
如何在春季使用Java 在Spring中通过@RequestParam发送%,java,spring,spring-mvc,http-request-parameters,Java,Spring,Spring Mvc,Http Request Parameters,如何在春季使用@RequestParam发送% 我通过以下URL调用API:http://localhost:8080/springmvc/test?param1=% 但我无法在API中获取%的值。调试时,我得到的是param1=null,但我想得到真正的字符%。怎么弄到的 这是我的API: public List<Test> testParam( @PathVariable("test") string test,
@RequestParam
发送%
我通过以下URL调用API:http://localhost:8080/springmvc/test?param1=%
但我无法在API中获取%的值。调试时,我得到的是param1=null
,但我想得到真正的字符%
。怎么弄到的
这是我的API:
public List<Test> testParam(
@PathVariable("test") string test,
@RequestParam(value = "param1", required = false) string myParaml) {
...
}
公共列表testParam(
@路径变量(“测试”)字符串测试,
@RequestParam(value=“param1”,required=false)字符串myParaml){
...
}
对特殊符号使用URL编码作为参数
% = %25
如果你想用Java阅读,你需要解码
您必须在URL中发送UTF-8编码标准的特殊字符 尝试将
%
作为%25
发送,这是UTF-8编码的等价物
http://localhost:8080/springmvc/test?param1=%25
这会奏效的。有关更多信息,请参阅