[英]Spring Controller: Passing Url As Parameter 404 Error
My controller attaches a question mark at the end of a string. 我的控制器在字符串末尾附加一个问号。 It works great for every types of string.
它适用于每种类型的字符串。
https://www.mywebsite.com/attachQuestionmark/33 returns 33?
https://www.mywebsite.com/attachQuestionmark/hello returns hello?
However it returns not found error for urls such as https:://www.test.com. 但是,对于诸如https :: //www.test.com之类的网址,它会返回未找到的错误。
https://www.mywebsite.com/attachQuestionmark/https:://www.test.com returns 404 error. https://www.mywebsite.com/attachQuestionmark/https:://www.test.com返回404错误。
Is there any way to pass a full url to spring mvc controller? 有什么办法可以将完整的URL传递给Spring MVC Controller吗?
@RequestMapping(
value = MyUrlBuilder.API_CREATIVE_CREATE + "/attachQuestionmark/{string}",
method = RequestMethod.GET,
produces = MediaType.ALL_VALUE)
@ResponseBody
@PMET
public static String attachQustionmark(@PathVariable("url") String value)
{
return value + "?";
}
Try URL-encoding the path variable, eg: 尝试对路径变量进行URL编码 ,例如:
https://www.mywebsite.com/attachQuestionmark/https%3A%3A%2F%2Fwww.test.com https://www.mywebsite.com/attachQuestionmark/https%3A%3A%2F%2Fwww.test.com
Because otherwise the / inside the variable will be interpreted as another path 因为否则变量中的/将被解释为另一个路径
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.