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,我無法得到。