Map-backed Actionform alternative in Struts 2

前端 未结 2 596
死守一世寂寞
死守一世寂寞 2021-01-01 04:50

In Struts 1, I have used map-backed action form to get dynamic fields values.

public MyForm extends ActionForm {
    private final Map values = new HashMap()         


        
2条回答
  •  醉话见心
    2021-01-01 05:24

    You can put your map directly to action class and in JSP use Struts2 tags to submit/get values.

    Action

    public class SaveAction extends ActionSupport {
        private Map map; 
    
        public String execute(){
          // do something with map
          return SUCCESS;
        }
    
        // getter/setter for map
    }
    

    JSP

    
      
      
    
    

提交回复
热议问题