图片上传拦截器配置

来源:互联网 发布:赵薇事件公知 编辑:程序博客网 时间:2024/06/13 04:51

<interceptors>
<interceptor name="MyInterceptor" class="com.servlet.interceptor.MyInterceptor"></interceptor>
<!-- 配置拦截器栈,集合 -->
<interceptor-stack name="myStack">
<!--自定义拦截器  -->
<interceptor-ref name="MyInterceptor"></interceptor-ref>
<!-- 默认拦截器栈,放后面,谁在前,谁先起作用,默认的拦截器栈无法传参 -->
<interceptor-ref name="defaultStack"></interceptor-ref>
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="myStack"></default-interceptor-ref>


<interceptor-ref name="fileUpload">           

     <param name="allowedTypes">image/bmp,image/png,image/gif,image/jpeg,image/pjpeg</param>   

<!-- 取其中一种-->   

<param name="allowedExtensions">png,jpg,xml,txt</param       

     <!-- 图片不能大于5M -->       

     <param name="maximumSize">5242880</param> 

</interceptor-ref>

<interceptor-ref name="defaultStack" /> 

阅读全文
0 0