我用新澤西的鏈接頭功能創建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) {...}