Spring mvc 在SpringMVC中禁用URL解码

Spring mvc 在SpringMVC中禁用URL解码,spring-mvc,spring-boot,kotlin,Spring Mvc,Spring Boot,Kotlin,我有以下几点 @RequestMapping("missedcall") fun missedCall(@RequestParam("v") encryptedValue : String, model: ModelMap): String { //decrypt encryptedValue here } 当我使用“”执行此端点时,encryptedValue初始化为“这是我的加密字符串”。事实上,我想要这些加号,因为它们是加密的一部分,没有它们我无法解密字符串 解决方法是URL编

我有以下几点

@RequestMapping("missedcall")
fun missedCall(@RequestParam("v") encryptedValue : String, model: 
ModelMap): String {
    //decrypt encryptedValue here
}
当我使用“”执行此端点时,encryptedValue初始化为“这是我的加密字符串”。事实上,我想要这些加号,因为它们是加密的一部分,没有它们我无法解密字符串

解决方法是URL编码字符串以还原加号和其他特殊字符,但是有更干净的方法吗?可能正在禁用此特定端点的URL解码


注意:我不能在正文中传递这个参数,它必须是查询字符串的一部分。这也是用Kotlin编写的,但我100%肯定Java也有类似的问题,所以不要因为Kotlin而气馁:)。

任何web框架都会为您解密查询路径,这是预期的行为。如果这不是您想要的,那么您必须定义HttpServletRequest类型的方法参数,并自己使用解析查询。

任何web框架都将为您解密查询路径,这是预期的行为。如果这不是您想要的,您必须定义一个HttpServletRequest类型的方法参数,并自己使用解析查询。

多亏了@SeanPatrickFloyd,它实现为

@RequestMapping("missedcall")
fun missedCall(request: HttpServletRequest, model: ModelMap): String {
    val encodedValue = request.queryString.split("=")[1]
    //decrypt encryptedValue here
}

多亏了@SeanPatrickFloyd,它实现为

@RequestMapping("missedcall")
fun missedCall(request: HttpServletRequest, model: ModelMap): String {
    val encodedValue = request.queryString.split("=")[1]
    //decrypt encryptedValue here
}