我的帖子方法使用以下代码返回创建的响应:
URI location = null;
try {
location = new URI("example");
} catch (URISyntaxException e) {
e.printStackTrace();
}
return Response.created(location).build();
我在浏览器/Postman上获得的响应位置标题是:
base-path-to-my-webapp/example
我期望base-path-to-my-web-app/current-path/example
我试图在线寻找这个问题。我得到了https://java.net/jira/browse/jersey-2838,它说问题已经解决,如果我们发布到current-path/
(带有落后的斜线(,我们应该得到正确的响应。
这似乎对我不起作用。我正在使用泽西2.23.2
查看从泽西岛2.22到2.22.1的迁移。它描述了所做的更改。如果您希望您期望的行为,请设置属性
ServerProperties.LOCATION_HEADER_RELATIVE_URI_RESOLUTION_RFC7231
to true
应该执行技巧。