【发布时间】:2014-12-15 17:32:18
【问题描述】:
我正在使用 Postman 在“form-data”选项下将 xml 文件作为附件发送。 我将“Content-Type”的请求标头添加为“multipart/form-data”
但我的端点没有获取 xml 文件。我的端点如何接收 xml 文件?
@PUT
@Path("/{param1}/{param2}")
@Consumes(MediaType.APPLICATION_XML)
@Produces(MediaType.APPLICATION_JSON)
public Response receiveXmlFile(List<Identifier> identifierList,
@PathParam("param1") String param1,
@PathParam("param2") String param2,
@FormParam("xmlFile") File xmlFile)
)
{
try {
return Response.status(Response.Status.OK).entity(readXmlFile(xmlFile)).build();
} catch (Exception e) {
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).header("error", e.getMessage()).build();
}
}
【问题讨论】:
标签: java xml rest servlets endpoint