Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring mvc 无效<;url模式>;在servlet映射中,如何删除此错误_Spring Mvc_Annotations_Url Parameters - Fatal编程技术网

Spring mvc 无效<;url模式>;在servlet映射中,如何删除此错误

Spring mvc 无效<;url模式>;在servlet映射中,如何删除此错误,spring-mvc,annotations,url-parameters,Spring Mvc,Annotations,Url Parameters,我正在使用这个函数获取请求参数Spring3MVC,我的url是 localhost:8080/karmaFriend/register/abc/wq/abc@abc.com @RequestMapping(value = "/register/{username}/{password}/{email}", method = RequestMethod.GET) public @ResponseBody ResponseMsg getUserInJSON(@PathVariable Stri

我正在使用这个函数获取请求参数Spring3MVC,我的url是

localhost:8080/karmaFriend/register/abc/wq/abc@abc.com

@RequestMapping(value = "/register/{username}/{password}/{email}",  method = RequestMethod.GET)

public @ResponseBody ResponseMsg getUserInJSON(@PathVariable String username, @PathVariable String password, @PathVariable String email) {
        ResponseMsg responseMsg = CommonUtils.checkParam(username, password, email);
        if(responseMsg.getStatus().equalsIgnoreCase("True"))
            responseMsg =  userService.registerUser(username, password, email);
        return responseMsg;
    }
它工作得很好,但如果我像这样更改我的url 本地主机:8080/friend/register/abc//abc@abc.com

@RequestMapping(value = "/register/{username}/{password}/{email}",  method = RequestMethod.GET)

public @ResponseBody ResponseMsg getUserInJSON(@PathVariable String username, @PathVariable String password, @PathVariable String email) {
        ResponseMsg responseMsg = CommonUtils.checkParam(username, password, email);
        if(responseMsg.getStatus().equalsIgnoreCase("True"))
            responseMsg =  userService.registerUser(username, password, email);
        return responseMsg;
    }

然后它将不会调用该函数。。。是否有其他方法调用相同的函数???

似乎您需要编写一个不同的方法:我不知道为什么您要注册一个没有用户名的人,但您可以在路径变量中使用正则表达式。尝试将用户名更改为“{username:^[\pL\pN\p{Pc}]*$}”,这很可能会占用0个或更多带有下划线字符的字母数字。你可能需要玩一下正则表达式。