Spring mvc 无效<;url模式>;在servlet映射中,如何删除此错误
我正在使用这个函数获取请求参数Spring3MVC,我的url是 localhost:8080/karmaFriend/register/abc/wq/abc@abc.comSpring 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
@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个或更多带有下划线字符的字母数字。你可能需要玩一下正则表达式。