Skip to content

Commit 91225ce

Browse files
committed
WW-4389 Solves typo in error message and introduces new message variable
1 parent bd56838 commit 91225ce

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

core/src/main/java/org/apache/struts2/interceptor/FileUploadInterceptor.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040

4141
import javax.servlet.http.HttpServletRequest;
4242
import java.io.File;
43+
import java.text.NumberFormat;
4344
import java.util.ArrayList;
4445
import java.util.Collection;
4546
import java.util.Collections;
@@ -350,7 +351,7 @@ protected boolean acceptFile(Object action, File file, String filename, String c
350351
LOG.warn(errMsg);
351352
}
352353
} else if (maximumSize != null && maximumSize < file.length()) {
353-
String errMsg = getTextMessage(action, "struts.messages.error.file.too.large", new String[]{inputName, filename, file.getName(), "" + file.length()});
354+
String errMsg = getTextMessage(action, "struts.messages.error.file.too.large", new String[]{inputName, filename, file.getName(), "" + file.length(), getMaximumSizeStr(action)});
354355
if (validation != null) {
355356
validation.addFieldError(inputName, errMsg);
356357
}
@@ -383,6 +384,10 @@ protected boolean acceptFile(Object action, File file, String filename, String c
383384
return fileIsAcceptable;
384385
}
385386

387+
private String getMaximumSizeStr(Object action) {
388+
return NumberFormat.getNumberInstance(getLocaleProvider(action).getLocale()).format(maximumSize);
389+
}
390+
386391
/**
387392
* @param extensionCollection - Collection of extensions (all lowercase).
388393
* @param filename - filename to check.

core/src/main/resources/org/apache/struts2/struts-messages.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ struts.messages.invalid.file=Could not find a Filename for {0}. Verify that a va
2727
struts.messages.invalid.content.type=Could not find a Content-Type for {0}. Verify that a valid file was submitted.
2828
struts.messages.removing.file=Removing file {0} {1}
2929
struts.messages.error.uploading=Error uploading: {0}
30-
struts.messages.error.file.too.large=The file is to large to be uploaded: {0} "{1}" "{2}" {3}
30+
struts.messages.error.file.too.large=File {0} is too large to be uploaded. Maximum allowed size is {4} bytes?
3131
struts.messages.error.content.type.not.allowed=Content-Type not allowed: {0} "{1}" "{2}" {3}
3232
struts.messages.error.file.extension.not.allowed=File extension not allowed: {0} "{1}" "{2}" {3}
3333

0 commit comments

Comments
 (0)