我用新泽西的链接头功能创建HTTP链接标题:@InjectLink的值中的问号编码为%3F。如何防止这一点?
@InjectLink(value="users/?orgId=12345&page=0",rel="first")
效果很好,除了问号 - 这是编码%3F和产生的URL看起来像: http://localhost:8080/app/users/%3ForgId=12345&page=0
我有什么防止编码和留下问号字符的方式是?
我用新泽西的链接头功能创建HTTP链接标题:@InjectLink的值中的问号编码为%3F。如何防止这一点?
@InjectLink(value="users/?orgId=12345&page=0",rel="first")
效果很好,除了问号 - 这是编码%3F和产生的URL看起来像: http://localhost:8080/app/users/%3ForgId=12345&page=0
我有什么防止编码和留下问号字符的方式是?
问题mar是为查询参数字符串编码的url,所以它的法线在你的路径中有%3。尝试使用'绑定'或将@Queryparams设置为这样How to force URIBuilder.path(...) to encode parameters like "%AD"? This method doesn't always encode parameters with percentage, correctly
这不适用于@InjectLink(value)
。建立URL参数应该被@InjectLink(method, bindings...)
使用。
例如:
@InjectLink(
resource = UserResource.class,
method ="getUserById",
bindings ={@Binding(name = "orgId", value = "${instance.orgId}")},
style = Style.ABSOLUTE,
...)
和目标新泽西资源UserResource.java:
@Path("users/{orgId}")
public User getUserById(@PathParam("orgId") String orgId) {...}