During file upload, we can specify the Interceptor to set the file type, extension name, and size. The configuration in the action is as follows:
<Interceptor-ref name = "fileupload">
<Param name = "maximumsize"> 500000 </param>
<Param name = "allowedtypes"> application/vnd. MS-Excel </param>
<Param name = "allowedextensionsset"> XLS </param>
</Interceptor-ref>
If the uploaded file does not conform to the definition, it will be switched to the input view. Obtain the error message <s: fielderror> </S: fielderror> on the page.
If you need to define your own prompt information, you can set the international configuration information and add it to the Struts. xml file? :
<Constant name = "struts. Custom. i18n. Resources" value = "message"> </constant>
Message indicates the attribute configuration file starting with message. The Chinese file name is message_zh_cn.properties.
You can customize the error message in message_zh_cn.properties:
Struts. Messages. Error. Uploading = \ u4e0a \ u4f20 \ u9519 \ u8bef
Struts. Messages. Error. file. Too. Large = \ u6587 \ u4ef6 \ u592a \ u5927
Struts. Messages. Error. content. type. Not. Allowed = \ u8bf7 \ u9009 \ u62e9excel \ u6587 \ u4ef6
Struts. Messages. Error. file. extension. Not. Allowed = \ u8bf7 \ u9009 \ u62e9.xls \ u7ed3 \ u5c3e \ u7684 \ u6587 \ u4ef6