How to exclude the submit action from a list of parameters in struts2?

后端 未结 1 553
生来不讨喜
生来不讨喜 2020-12-06 21:40

I\'m trying to exclude a submit action from a parameter list. The following is the action class.

@Namespace(\"/admin_side\")
@ResultPath(\"/WEB-INF/content\"         


        
1条回答
  •  -上瘾入骨i
    2020-12-06 22:21

    Why doesn't it exclude the submit button's parameter?

    Because this parameter is in the excludeParams list of the params interceptor in the defaultStack which your action is referenced by default.

    How to invoke the postAction() method, when is clicked?

    In this question you ask how to invoke a method (not an action). The difference between the action and method the first is mapped to a specified URL using a namespace and action name. So, to invoke a method other than an action you should turn DMI on. Struts, since 2.3.16 turned off this option. The following configuration constant to use in struts.xml:

    
    

    and use a method attribute instead of action attribute.

    
      
     
    

    as I already told in this answer.

    If you don't want to use DMI, then you have an option to enable action: prefix to the parameter

    
    

    and use an action mapped to the method postAction

    
      
     
    

    and use annotation without params.excludeParams.

    @InterceptorRef(value="defaultStack" params={"validation.excludeMethods", "test"})
    

    The warning that action:postAction parameter is on exclude list still persist, but it appears only if the struts.devMode=true. You shouldn't worry about it because it warns all parameters from the excludeParams list that passed through. To turn off devMode you should set

    
    

    0 讨论(0)
提交回复
热议问题