Chào các bác, mình có một đoạn controller về upload file như sau:
@POST
@Path("class/import")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.APPLICATION_JSON)
@RolesAllowed(Role.TRAINING_ADMIN)
public Response importClass(@FormParam("file") File file) {
LOGGER.info("Received PUT import class: file=" + file.length());
if (checkTokenAndRole(new int[] {1, 11}).getStatus() != Response.Status.OK.getStatusCode()) {
return LoginError(checkToken().getStatus());
} else {
String token = request.getHeader(HttpHeaders.AUTHORIZATION);
String fileExtension = request.getHeader("FileExtension");
return ClassService.getInstance().importClass(file, fileExtension,
token);
}
}
Đoạn code này chạy ổn trên java 6, JPA 2.0, Websphere Application Server 8.5. Nhưng khi chuyển qua môi trường java 8, JPA 2.1, Websphere Application Server 9.0 thì bị báo lỗi như sau:
Illegal URL-encoded characters, make sure that no @FormParam and @Multipart annotations are mixed up
Mình có thử chuyển @FormParam thành @Multipart thì chạy được, nhưng lại không thể đọc được đúng signature header của file upload.
Ai rành về Websphere có thể giúp mình đưa ra cách nào để có thể dùng tiếp @FormParam mà không bị lỗi trên được không?
Mình xin cảm ơn.
83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?