这是我的struts。xml
配置文件,其中我有一个登录拦截器。我想使用不同的文件上传拦截器,在不同的操作中使用不同的文件类型和给定的最大大小。但问题就在这里:它总是采用默认的maximumSize
和allowedType
。我哪里做错了?
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.enable.DynamicMethodInvocation"
value="false" />
<constant name="struts.devMode" value="false" />
<constant name="struts.custom.i18n.resources"
value="ApplicationResources" />
<package name="default" extends="struts-default" namespace="/">
<result-types>
<result-type name="tiles"
class="org.apache.struts2.views.tiles.TilesResult" />
</result-types>
<interceptors>
<interceptor name="nlogin" class="com.picvik.interceptor.LoginInterceptor"/>
<interceptor-stack name="loginStack">
<interceptor-ref name="servletConfig"/>
<interceptor-ref name="params"/>
<interceptor-ref name="nlogin"/>
<interceptor-ref name="prepare"/>
<interceptor-ref name="chain"/>
<interceptor-ref name="modelDriven"/>
<interceptor-ref name="staticParams"/>
<interceptor-ref name="params"/>
<interceptor-ref name="conversionError"/>
<interceptor-ref name="validation"/>
<interceptor-ref name="workflow"/>
</interceptor-stack>
</interceptors>
<!-- <default-interceptor-ref name="loginStack"/> -->
<global-results>
<result name="login" type="tiles">/login.tiles</result>
</global-results>
<action name="home"
class="com.picvik.action.HomeAction">
<interceptor-ref name="loginStack"/>
<result name="success" type="tiles">/home.tiles</result>
<result name="error" type="tiles">/welcome.tiles</result>
</action>
<action name="registration"
class="com.picvik.action.RegisterAction" method="execute">
<result name="success" type="tiles">/register.tiles</result>
</action>
<action name="register"
class="com.picvik.action.RegisterAction" method="register">
<result name="success" type="tiles">/registerverify.tiles</result>
<result name="error" type="tiles">/register.tiles</result>
<result name="input" type="tiles">/register.tiles</result>
</action>
<action name="verify"
class="com.picvik.action.RegisterAction" method="verify">
<result name="success" type="tiles">/login.tiles</result>
<result name="error" type="tiles">/registerverify.tiles</result>
</action>
<action name="login" class="com.picvik.action.LoginAction">
<result name="success" type="tiles">/home.tiles</result>
<result name="input" type="tiles">/login.tiles</result>
</action>
<action name="dologin" class="com.picvik.action.LoginAction" method="login">
<interceptor-ref name="defaultStack"/>
<result name="success" type="tiles">/home.tiles</result>
<result name="input" type="tiles">/login.tiles</result>
</action>
<action name="logout" class="com.picvik.action.LoginAction" method="logout">
<interceptor-ref name="defaultStack"/>
<result name="success" type="tiles">/login.tiles</result>
</action>
<action name="viewprofile" class="com.picvik.action.ViewProfileAction">
<interceptor-ref name="loginStack"/>
<result name="success" type="tiles">/viewprofile.tiles</result>
</action>
<action name="editprofile" class="com.picvik.action.ViewProfileAction">
<interceptor-ref name="loginStack"/>
<result name="success" type="tiles">/editprofile.tiles</result>
</action>
<action name="saveprofile" class="com.picvik.action.ViewProfileAction" method = "saveProfile">
<interceptor-ref name="loginStack"/>
<result name="success" type="tiles">/home.tiles</result>
<result name="input" type="tiles">/editprofile.tiles</result>
</action>
<action name="changeprofilephoto" class="com.picvik.action.ChangeProfilePhotoAction">
<interceptor-ref name="loginStack"/>
<result name="success" type="tiles">/changephoto.tiles</result>
<result name="input" type="tiles">/changephoto.tiles</result>
</action>
<action name="uploadprofilephoto"
class="com.picvik.action.ChangeProfilePhotoAction" method="uploadProfilePhoto">
<interceptor-ref name="fileUpload">
<param name="maximumSize">2097152</param>
<param name="allowedTypes">
image/png,image/gif,image/jpeg,image/pjpeg
</param>
</interceptor-ref>
<interceptor-ref name="loginStack"></interceptor-ref>
<result name="success" type= "redirectAction">
<param name="actionName">viewprofile</param>
</result>
<result name="input" type="tiles">/changephoto.tiles</result>
</action>
<!-- video upload-->
<action name="videouploader"
class="com.picvik.action.UploadVideoAction" method="execute">
<interceptor-ref name="loginStack"></interceptor-ref>
<result name="success" type="tiles">/videoupload.tiles</result>
</action>
<action name="uploadvideo"
class="com.picvik.action.UploadVideoAction" method="uploadVideo">
<interceptor-ref name="fileUpload">
<param name="maximumSize">209715200</param>
<param name="allowedTypes">
video/mp4
</param>
</interceptor-ref>
<interceptor-ref name="loginStack"></interceptor-ref>
<result name="success" type= "redirectAction">
<param name="actionName">editvideo</param>
</result>
<result name="input" type="tiles">/videoupload.tiles</result>
</action>
<action name="editvideo"
class="com.picvik.action.UploadVideoAction" method="editVideo">
<interceptor-ref name="loginStack"></interceptor-ref>
<result name="success" type= "redirectAction">
<param name="actionName">home</param>
</result>
<result name="input" type="tiles">/editvideo.tiles</result>
</action>
<action name="savevideos"
class="com.picvik.action.UploadVideoAction" method="saveVideo">
<interceptor-ref name="loginStack"></interceptor-ref>
<result name="success" type= "redirectAction">
<param name="actionName">listVideo</param>
</result>
<result name="error" type="tiles">/editvideo.tiles</result>
</action>
<!-- video upload ends here-->
<!-- photo upload -->
<action name="photouploader"
class="com.picvik.action.UploadPhotoAction">
<interceptor-ref name="loginStack"></interceptor-ref>
<result name="success" type="tiles">/photoupload.tiles</result>
</action>
<action name="uploadphoto"
class="com.picvik.action.UploadPhotoAction" method="uploadPhoto">
<interceptor-ref name="fileUpload">
<param name="maximumSize">20971520</param>
<param name="allowedTypes">
image/png,image/gif,image/jpeg,image/pjpeg
</param>
</interceptor-ref>
<interceptor-ref name="loginStack"></interceptor-ref>
<result name="success" type= "redirectAction">
<param name="actionName">editphoto</param>
</result>
<result name="input" type="tiles">/photoupload.tiles</result>
</action>
<action name="editphoto"
class="com.picvik.action.UploadPhotoAction" method="editPhoto">
<interceptor-ref name="loginStack"></interceptor-ref>
<result name="success" type= "redirectAction">
<param name="actionName">home</param>
</result>
<result name="input" type="tiles">/editphoto.tiles</result>
</action>
<action name="savephotos"
class="com.picvik.action.UploadPhotoAction" method="savePhoto">
<interceptor-ref name="loginStack"></interceptor-ref>
<result name="success" type= "redirectAction">
<param name="actionName">listalbum</param>
</result>
<result name="error" type="tiles">/editphoto.tiles</result>
</action>
<action name="listalbum"
class="com.picvik.action.ViewAlbumAction" method="listAlbum">
<interceptor-ref name="loginStack"></interceptor-ref>
<result name="success" type="tiles">/listalbum.tiles</result>
</action>
<action name="listphoto"
class="com.picvik.action.ViewAlbumAction" method="listPhoto">
<interceptor-ref name="loginStack"></interceptor-ref>
<result name="success" type="tiles">/listphoto.tiles</result>
</action>
<action name="listalbumphoto"
class="com.picvik.action.ViewAlbumAction" method="listAlbumPhoto">
<interceptor-ref name="loginStack"></interceptor-ref>
<result name="success" type="tiles">/listalbumphoto.tiles</result>
</action>
<action name="viewphoto"
class="com.picvik.action.ViewAlbumAction" method="viewPhoto">
<interceptor-ref name="loginStack"></interceptor-ref>
<result name="success" type="tiles">/viewphoto.tiles</result>
</action>
<action name="commentonphoto"
class="com.picvik.action.CommentAction" method="commentOnPhoto">
<interceptor-ref name="loginStack"></interceptor-ref>
<result name="success" type= "redirectAction">
<param name="actionName">listphoto</param>
</result>
</action>
<action name="commentonalbum"
class="com.picvik.action.CommentAction" method="commentOnAlbum">
<interceptor-ref name="loginStack"></interceptor-ref>
<result name="success" type= "redirectAction">
<param name="actionName">listalbum</param>
</result>
</action>
</package>
使用以下配置属性重写缺省值
struts.multipart.maxSize=2097152
这是从默认值中获取的。财产。请注意,末尾没有0
。
检查如何使用fileUpload
拦截器的文档和示例。
本文向大家介绍Vue 前端实现登陆拦截及axios 拦截器的使用,包括了Vue 前端实现登陆拦截及axios 拦截器的使用的使用技巧和注意事项,需要的朋友参考一下 该项目是利用了Github 提供的personal token作为登录token,通过token访问你的Repository List。通过这个项目学习如何实现一个前端项目中所需要的 登录及拦截、登出、token失效的拦截及对应 axi
问题内容: 我知道如何拦截所有请求,但是我只想拦截来自我资源的请求。 有谁知道如何做到这一点? 问题答案: 如果只想拦截来自特定资源的请求,则可以使用可选的action 属性。Angular的文档请参见此处(用法>操作) 的JavaScript Plunker:http ://plnkr.co/edit/xjJH1rdJyB6vvpDACJOT?p=preview
本文向大家介绍浅析java中 Spring MVC 拦截器作用及其实现,包括了浅析java中 Spring MVC 拦截器作用及其实现的使用技巧和注意事项,需要的朋友参考一下 拦截器的实现 1、编写拦截器类实现HandlerInterceptor接口; 2、将拦截器注册进springmvc框架中; 3、配置拦截器的拦截规则; 其他实现方法 WebRequestInterceptor接口: 与上一个
1. 前言 拦截器这个名词定义的非常形象,就像导弹要攻击目标的时候,可能会被先进的反导系统拦截,此处的反导系统就是一种拦截器。 我们开发的应用,对外暴露的是控制器中定义的 API 方法,我们可以在 API 方法的外围放置拦截器,所有对 API 的访问都可以通过拦截器进行过滤。 OK,那么这样的拦截有什么意义吗,其实已经很明显了,反导系统可以保护目标的安全并识别对目标的攻击行为。同理,拦截器可以跟踪
我想添加spring mvc拦截器作为Java配置的一部分。我已经有了一个基于xml的配置,但是我正在尝试使用Java的配置。对于拦截器,我从spring的文档中知道可以这样做- 但我的拦截器使用了一个spring豆,就像下面这样- SomeService类如下所示- 我使用这样的注释来扫描bean,并且没有在配置类中将它们指定为 根据我的理解,由于Java配置使用new来创建对象,所以sprin
问题内容: 使用笑话进行测试时,我具有基本的测试服语法: 问题是我的代码中有拦截器,当使用jest命令输出运行测试时,拦截器会: TypeError:无法读取未定义的属性“拦截器” 并指向拦截器对象 是存储以下项的返回值的变量 在SO上引用了该axios线程。我如何以开玩笑的方式测试axios,但是它不涉及任何拦截器,因此并没有真正的帮助。 问题答案: 最后就足够了