Struts2: method attribute in button doesn't work

前端 未结 1 1696
[愿得一人]
[愿得一人] 2020-12-06 02:44

I have a form in jsp. There are two submit buttons: \"Search\" and \"Add New\" button. I had set each button with their own method attribute.



        
1条回答
  •  攒了一身酷
    2020-12-06 03:18

    Set

    
    

    to

    
    

    Another way is to define multiple mappings for the same Action, like

    in JSP:

    
    
    

    in Struts.xml

    
           /example/search.jsp
    
    
           /example/add.jsp
    
    

    A third way is to use Wildcard Mappings.

    P.S: If you go for the second one, I'll suggest, as a best practice, to use one Action for every logical action you have to perform...

    If you have common data loaded / managed by both your actions, "search" and "addNew", then you can define a employeeBaseAction, extended by both employeeSearchAction and employeeAddNewAction.


    EDIT

    It's 2014 now, and DMI usage is unanimously discouraged (today more than ever), other than pretty useless, so I strongly suggest you to use solution n.2.

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