Java .z后缀将得到';406不可接受';restful web服务中的错误
我有一个RESTURI,如Java .z后缀将得到';406不可接受';restful web服务中的错误,java,spring,rest,spring-mvc,restful-url,Java,Spring,Rest,Spring Mvc,Restful Url,我有一个RESTURI,如http://127.0.0.1:9000/users/{username}基于spring MVC 如果我分配x@y.com或x@y.a到{username},它工作得很好 但是,如果我分配x@y.z到{username},客户端将获得406不可接受的错误,可以接收请求,并且服务端没有发生错误 这意味着: http://127.0.0.1:9000/users/x@y、 a好 http://127.0.0.1:9000/users/x@y、 comGood http:
http://127.0.0.1:9000/users/{username}
基于spring MVC
如果我分配x@y.com
或x@y.a
到{username}
,它工作得很好
但是,如果我分配x@y.z
到{username}
,客户端将获得406不可接受的
错误,可以接收请求,并且服务端没有发生错误
这意味着:
http://127.0.0.1:9000/users/x@y、 a
好
http://127.0.0.1:9000/users/x@y、 com
Good
http://127.0.0.1:9000/users/x@y、 z
错误(客户端不接受406)
有人能解释一下为什么x@y.a
和x@y.com
可以工作,但x@y.z
不能吗
谢谢
请按以下方式查找控制器
@RequestMapping("/users/{login}")
public UserProfile getUserProfile(@PathVariable("login") String login) {
log.info(String.format("Get user profile by login %s", login));
UserProfile userProfile = userProfileRepo.getUserProfile(login);
if (userProfile == null) {
log.info(String.format("User profile is null for user %s", login));
userProfile = new UserProfile();
userProfile.setLogin(login);
userProfileRepo.save(userProfile);
return new UserProfile();
}
return userProfile;
}
一个有用的发现,唯一的日志显示
x@y.z
被截断为x@y
:
User profile is null for user x@y
同时,如果我将path变量从@PathVariable移动到@RequestParam,它就会工作
因此,当将路径变量{username}分配给
x@y.z
,仅限x@y
可以分配,谁知道为什么?让我们看看您的MVC配置。我使用的是spring boot,spring MVC是自动配置的,请查找。否,我想让你在问题中发布你的@Controller
和你的配置。@SotiriosDelimanolis是否嵌入了tomcat拒绝.z后缀?如果是,您知道服务部门为什么接收并处理该请求吗?@SotiriosDelimanolis我添加了它。