shengke
2015-01-29 16:16:22
原
java struts2实现文件批量上传下载功能(实现国际化配置)
前几个代码都是用servlet实现的,这个是使用struts2框建实现。供大家参考!
具体实现就不一一说明了,大致如下
首先把struts2的框架搞定,可以到apache官网上下载,我是在这下载的http://down2.pc6.com/xy3/struts2.zip,
解压——》apps(一些小demo)——》解压struts2-blank.war(主要使用里面的jar)——》复制/apps/struts2-blank/WEB-INF/lib下的jar到你项目的lib下——》配置web.xml,添加如下内容:
<!-- struts2配置 --> <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
——》在src下把小demo里的struts.xml拷贝过来删除不需要的,配置自己的action。
国际化配置:
在参考文档:/docs/WW/docs/file-upload-interceptor.html里有异常的解说,可以按照里面的异常提示,来写自己的国际化
- struts.messages.error.uploading - a general error that occurs when the file could not be uploaded
- struts.messages.error.file.too.large - occurs when the uploaded file is too large
- struts.messages.error.content.type.not.allowed - occurs when the uploaded file does not match the expected content types specified
- struts.messages.error.file.extension.not.allowed - occurs when the uploaded file does not match the expected file extensions specified
根据自己的需求, 建立app_zh_CN.properties,内容如下
struts.messages.error.file.too.large=\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F\u8D85\u9650\uFF01
文件过大的提示
struts.messages.error.content.type.not.allowed=\u4E0A\u4F20\u6587\u4EF6\u7C7B\u578B\u4E0D\u6B63\u786E\uFF01
文件类型不匹配的提示
猜你喜欢
请下载代码后再发表评论
文件名:fileWithStruts2.zip,文件大小:4148.824K
下载
- /
- /fileWithStruts2
- /fileWithStruts2/.settings
- /fileWithStruts2/WebContent
- /fileWithStruts2/WebContent/META-INF
- /fileWithStruts2/WebContent/css
- /fileWithStruts2/WebContent/images
- /fileWithStruts2/WebContent/js
- /fileWithStruts2/WebContent/jsp
- /fileWithStruts2/WebContent/META-INF
- /fileWithStruts2/build
- /fileWithStruts2/src
- /fileWithStruts2/src/com
- /fileWithStruts2/src/com/shengke
- /fileWithStruts2/src/com
- /fileWithStruts2/.settings
- /fileWithStruts2
![最代码相关代码源代码列表](https://static.zuidaima.com/resource/img/heart_ico.png)
![最代码最近下载分享源代码列表](https://static.zuidaima.com/resource/img/heart_ico.png)
wade123 LV31
2021年4月5日
死了还要爱 LV19
2020年9月6日
王晓敏 LV5
2020年5月18日
Chloez LV7
2019年4月24日
best2018 LV46
2019年3月6日
大鹏小镇 LV14
2018年7月17日
root321 LV13
2018年1月1日
lizelin2236 LV7
2017年11月10日
wang888999 LV5
2017年8月9日
641031823 LV4
2017年5月2日
![最代码最近浏览分享源代码列表](https://static.zuidaima.com/resource/img/cattle_ico.png)
wangshule LV14
1月8日
WBelong LV7
2023年12月11日
uni-code_0123 LV1
2023年11月29日
qwerasdf123456 LV2
2022年4月24日
雷迪斯俺的乡亲们 LV11
2022年3月9日
zhangmingzuidaima LV3
2021年12月16日
dongzhan LV12
2021年12月15日
不停yayaya LV4
2021年11月22日
EAST_Ace LV4
2021年11月3日
zql666 LV9
2021年9月28日