Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/11.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
Java .z后缀将得到';406不可接受';restful web服务中的错误_Java_Spring_Rest_Spring Mvc_Restful Url - Fatal编程技术网

Java .z后缀将得到';406不可接受';restful web服务中的错误

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:

我有一个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、 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我添加了它。