【问题标题】:Modify endpoint to receive an XML file修改端点以接收 XML 文件
【发布时间】: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


    【解决方案1】:

    解决方案是不要从邮递员那里发送multipart/form-data 标头。

    当发送相同的请求但没有任何标头时,我的端点成功接收到文件。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-10
      • 1970-01-01
      相关资源
      最近更新 更多