Multiple Entrypoints in Struts Action (Migration Struts 2.2.3 -> 2.3.1)

后端 未结 2 812
小蘑菇
小蘑菇 2021-01-13 15:14

I have an action in struts.xml


        
              


        
相关标签:
2条回答
  • 2021-01-13 16:09

    This happens because you have turned off DMI. The method attribute works with submit tag as before even after resent security fixes. Enable DMI using the constant

    <constant name="struts.enable.DynamicMethodInvocation" value="true"/> 
    

    let me know if it didn't work.

    0 讨论(0)
  • 2021-01-13 16:18

    If anyone is moving or working on Struts 2.5 then they don't have to map actions using struts.xml. Strtus 2.5 is annotation based so in action class developer can map multiple actions within in single class using annotation.

    May be this link helpful from old struts versions to struts 2.5 version.

    https://struts.apache.org/docs/struts-23-to-25-migration.html

    Following is the simple demo code.

    package com.stsh.action;
    
    import org.apache.struts2.convention.annotation.Action;
    import org.apache.struts2.convention.annotation.Namespace;
    import org.apache.struts2.convention.annotation.ParentPackage;
    import org.apache.struts2.convention.annotation.Result;
    
    import com.opensymphony.xwork2.ActionSupport;
    import com.stsh.intercepter.AuthRequired;
    
    @ParentPackage(value="default")
    @Namespace(value="/dashboard")
    public class DashboardAction extends ActionSupport implements AuthRequired{
    
        private static final long serialVersionUID = 1L;
    
        @Action(value = "home", results = { @Result(name = "success", location = "dashboard.tiles", type = "tiles") })
        public String dashboard(){
            return "success";
        }
    }
    
    0 讨论(0)
提交回复
热议问题