有没有办法知道 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;
}
现在首先浏览器将发送一个预检请求。有没有办法可以操纵预检请求的响应标头?