我见过允许CORS support...but w.e的帖子,我试过,我有0的运气。
下面是CORS在我的angular.js上的函数:
var config = {
method: 'GET',
url: "//localhost:8080/ScienceCompanionApp/service/bpms/task/5497d038-82da-4a4e-83bd-2ef01b30de1a",
headers: {
'BPM-CONTEXT-ID':'CONTEXT',
'Accept': 'application/json',
'Content-type': 'application/json'
}
}
$http(config).success(function(data,status,headers){ //do stuff here }
我在我的web.xml中添加了以下内容:
<filter>
<filter-name>CorsFilter</filter-name>
<filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>CorsFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
他们说,这是因为it...but似乎没有做到这一点,同时试图给CORS打电话:
然后,我尝试手动将它添加到REST中:
@Path("/task/{taskId}")
@GET
@ApiOperation(value="Get BPMS Task", notes="You will need to JS decrypt Header param before sending")
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public Response getTask(@ApiParam(value="bpmWorklistTaskId in the BPMS url")@PathParam("taskId") final String taskId,
@ApiParam(value="bpmWorklistContext in the bpms url")@HeaderParam(WORKFLOW_CONTEXT_HEADER) final String contextId) {
logger.info("REST : getTask(" + taskId + ", " + contextId + ")");
try {
return Response.status(200).entity(requestProcessor.getTaskDetails(taskId, contextId)).header("Access-Control-Allow-Origin", "*")
.header("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT, OPTIONS").header("Access-Control-Allow-Headers", "X-Requested-With, Content-Type, X-Codingpedia").build();
} catch (Exception e) {
throw createWebException(e);
}
}
@Path("/task/{taskId}")
@OPTIONS
public Response getOptions(@ApiParam(value="bpmWorklistTaskId in the BPMS url")@PathParam("taskId") final String taskId,
@ApiParam(value="bpmWorklistContext in the bpms url")@HeaderParam(WORKFLOW_CONTEXT_HEADER) final String contextId)
{
return Response.ok()
.header("Access-Control-Allow-Origin", "*")
.header("Access-Control-Allow-Methods", "POST, GET, PUT, UPDATE, OPTIONS")
.header("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With,BPM-CONTEXT-ID,accept,bpm-context-id").build();
}
仍然没有运气:
我是不是遗漏了什么?
发布于 2016-05-12 02:09:27
执行以下步骤
CORSFilter filter.CORSResponseFilter
< /filter>
<过滤器-映射>
CORSFilter /*
希望这能帮到你..。
https://stackoverflow.com/questions/25210210
复制相似问题