开发者

How to get PathVariable (String) in a Controller method

开发者 https://www.devze.com 2023-04-09 10:53 出处:网络
@RequestMapping(value = \"/user/search/{email}\") public String auditUseremail(@PathVariable(\"email\") String email,Map<String, Object> map) {
@RequestMapping(value = "/user/search/{email}")
    public String auditUseremail(@PathVariable("email") String email,Map<String, Object> map) {

        System.out.println(email);
}

this is my conroller class function, which is called when the action is http://localhost:8080/LACASServer/secure/user/search/user@cohaesus.co.uk

as u can look, email is in URL, but when i print it in the above method, i get it user@cohaesus.co, can an开发者_StackOverflowybody tell me, what can be the issue and how to resolve it.


I think you should use URL Encoding for this path and then decode it inside of controller

java.net.URLEncoder.encode(email, "ISO-8859-1");

You can read more about it here

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号