0
我有一个Web应用程序,在后端使用前端和Resteasy + Jackson的Angularjs。我送从角组件文件到REST方法,接收方法是这样的:Resteasy总是根据请求获取应用程序/ json内容类型
@POST
@Path("/upload/attachment/for/{eventId}")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response uploadFile(MultipartFormDataInput input,
final @PathParam("eventId") Long eventId,
@Context HttpServletRequest request) {
Map<String, List<InputPart>> uploadForm = input.getFormDataMap();
...my awesome stuff...
return Response.ok().build();
}
,并要求有以下标题发送时:
Accept application/json, text/plain, */*
Accept-Encoding gzip, deflate
Accept-Language en-US,en;q=0.5
Content-Length 347085
Content-Type multipart/form-data; boundary=---------------------------12164806981346771846716776342
Cookie JSESSIONID=aoBd1hgzR3GM8bSG5P-9g-vQ; csrftoken=ziQ7kN7TlMehR2aURDrmaMLYAroMsSpu
Host localhost:9000
Referer http://localhost:9000/local/myapp/index.html
User-Agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:32.0) Gecko/20100101 Firefox/32.0
的问题是,这个请求总是有application/json
作为内容类型而不是multipart/form-data
,正如它在标题中所述。我得到:
20:12:00,490 WARN [org.jboss.resteasy.core.SynchronousDispatcher] (http-/127.0.0.1:8080-2) Failed executing POST /events/upload/attachment/for/null: org.jboss.resteasy.spi.UnsupportedMediaTypeException: Cannot consume content type
已经在HttpServletDispatcher
的内容是错误的。
如果这是将Content-Type设置为错误值或其他某些东西的JBOSS,我无法得到。