[英]Is there a way to detect a preflight request in REST API Jersey?
有沒有辦法知道Java Jersey中的預檢請求標頭,還是有辦法向預檢請求發送不同的響應?
假設我有以下代碼:
@Path("/releaseClient")
@POST
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public JSONObject releaseClient(JSONObject clientAndUser, @Context HttpServletRequest request) throws JSONException{
int clientId = clientAndUser.getInt("id");
String userId = clientAndUser.getString("user");
JSONObject res = new JSONObject();
// Check if profile is locked by current user and if so release profile
if(clientLockService.unlockClient(clientId, userId)){
res.put("success", clientService.returnClientInfo(clientId));
} else {
// If not then set error message
res.put("error", "Profile is not locked by current user");
}
return res;
}
現在,首先瀏覽器將發送預檢請求。 有沒有一種方法可以操縱預檢請求的響應標頭 ?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.