2.7.11.6. 多部分消息的内容类型覆盖
通过使用拦截器和 InputPart.DEFAULT_CONTENT_TYPE_PROPERTY 属性,您可以设置默认的 Content-Type。您还可以通过调用 org.jboss.resteasy.plugins.providers.multipart.InputPart.setMediaType() 。
在任何输入部分中覆盖 Content- Type
示例:覆盖 Content-Type
@POST
@Path("query")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.TEXT_PLAIN)
public Response setMediaType(MultipartInput input) throws IOException {
List<InputPart> parts = input.getParts();
InputPart part = parts.get(0);
part.setMediaType(MediaType.valueOf("application/foo+xml"));
String s = part.getBody(String.class, null);
...
}