When catching a FileUploadException in the
AbstractMultiPartRequest.parse() method, if the final "else" is reached,
the default message
"struts.messages.upload.error.FileUploadException=Error uploading: {0}!"
(struts-messages.properties) always displays the "{0}" instead of
replacing it with the actual filename. In looking at the code, it might
be difficult to bubble up the filename from the source of the exception,
but that would be the preferred solution. Otherwise, it might make
sense to change the default upload error message without the {0}
parameters (e.g. "Error uploading the file", or "Error parsing the
request."). Thoughts?
[AbstractMultiPartRequest.java]
public void parse(HttpServletRequest request, String saveDir) throws
IOException {
try {
processUpload(request, saveDir);
} catch (FileUploadException e) {
LOG.debug("Request exceeded size limit!", e);
LocalizedMessage errorMessage;
if (e instanceof FileUploadByteCountLimitException ex) {
errorMessage = buildErrorMessage(e, new Object[]{
ex.getFieldName(), ex.getFileName(),
ex.getPermitted(), ex.getActualSize()
});
} else if (e instanceof FileUploadFileCountLimitException
ex) {
errorMessage = buildErrorMessage(e, new Object[]{
ex.getPermitted(), ex.getActualSize()
});
} else if (e instanceof FileUploadSizeException ex) {
errorMessage = buildErrorMessage(e, new Object[]{
ex.getPermitted(), ex.getActualSize()
});
} else if (e instanceof FileUploadContentTypeException ex) {
errorMessage = buildErrorMessage(e, new Object[]{
ex.getContentType()
});
// FINAL ELSE
} else {
errorMessage = buildErrorMessage(e, new Object[]{});
}
if (!errors.contains(errorMessage)) {
errors.add(errorMessage);
}
} catch (IOException e) {
LOG.debug("Unable to parse request", e);
LocalizedMessage errorMessage = buildErrorMessage(e, new
Object[]{});
if (!errors.contains(errorMessage)) {
errors.add(errorMessage);
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@struts.apache.org
For additional commands, e-mail: dev-h...@struts.apache.org