Struts2文件上传(二)-文件上传拦截器
来源:互联网 发布:泰拉瑞亚存档导入软件 编辑:程序博客网 时间:2024/05/24 02:28
看官方文档学习了一下,稍微记录一下。
File Upload Interceptor
1.该拦截器有三个可选参数
- maximumSize:文件的最大字节数,默认是2M。注意,它和 struts.multipart.maxSize 是有区别的
文档上的描述:
There are two separate file size limits. First is struts.multipart.maxSize which comes from the Struts 2 default.properties file. This setting exists for security reasons to prohibit a malicious user from uploading extremely large files to file up your servers disk space. This setting defaults to approximately 2 megabytes and should be adjusted to the maximum size file (2 gigs max) that your will need the framework to receive. If you are uploading more than one file on a form the struts.multipart.maxSize applies to the combined total, not the individual file sizes. The other setting, maximumSize, is an interceptor setting that is used to ensure a particular Action does not receive a file that is too large.
- allowedTypes:允许上传的文件类型,如 text/html ,text/plain
- allowedExtensions:允许上传的文件的后缀,如 .html
如果文件不符合设置,会产生相应的错误。
2.错误类型
- 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 expectedcontent types specified
- struts.messages.error.file.extension.not.allowed - occurs when the uploaded file does not match the expectedfile extensions specified
3.配置文件
<action name="upload" class="org.ygy.action.DocumentAction" method="upload"> <interceptor-ref name="fileUpload"> <param name="allowedTypes">image/jpeg</param> <param name="maximumSize">10240</param> </interceptor-ref> <interceptor-ref name="defaultStack" /> <result name="input">/upload.jsp</result>//出错后,返回界面 <result name="success">/upload_success.jsp</result> </action>
- Struts2文件上传(二)-文件上传拦截器
- struts2 拦截器上传文件
- Struts2上传文件拦截器实现文件上传
- Struts2 文件上传拦截器配置问题
- struts2 文件上传的拦截器问题
- Struts2文件上传 +自定义拦截器
- Struts2 文件上传fileUpload拦截器不起作用
- struts2--文件上传和uploadFile拦截器
- struts2--文件上传和uploadFile拦截器
- struts2--文件上传和uploadFile拦截器
- struts2--文件上传和uploadFile拦截器
- struts2--文件上传和uploadFile拦截器
- Struts2文件上传-fileUpload拦截器
- struts2实现文件上传(配置拦截器)
- struts2 文件上传的拦截器问题
- Struts2文件上传拦截器问题
- Struts2文件上传-fileUpload拦截器
- Struts2拦截器的应用:文件上传
- 实现Android和PC之间的蓝牙通信
- uBuntu wine字体设置
- 2013plan
- 黑马程序员 Java基础<一>---> 面向对象与类之概述(匿名对象、封装、构造函数、this、静态等)
- IOS调试技巧:当程序崩溃的时候怎么办 iphone IOS
- Struts2文件上传(二)-文件上传拦截器
- 我的初梦《梦幻重游》开发记录三
- rt-thread的IPC机制之互斥锁源码分析
- 删除文件夹里所有的.svn文件
- Ubuntu 12.04安装虚拟工具VMware Tools
- linux/unix shell的find用法小练
- 西电ACM2013年2月月赛--XDUOJ
- hdu 2060 snooker
- JQuery 插件 参考网站