Я хочу, чтобы при нажатии на обновление или удаление «Пользовательский метод внутреннего отображения» отображался на моем jsp.
Файл конфигурации Struts
Код: Выделить всё
Код: Выделить всё
public class UserAction extends DispatchAction {
/* forward name="success" path="" */
private final static String SUCCESS = "success";
/**
* This is the Struts action method called on
* http://.../actionPath?method=myAction1,
* where "method" is the value specified in element :
* ( )
*/
public ActionForward add(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
UserForm userForm = (UserForm) form;
return mapping.findForward("dispatch");
}
public ActionForward update(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
UserForm userForm = (UserForm) form;
userForm.setMessage("Inside update user method.");
return mapping.findForward(SUCCESS);
}
public ActionForward delete(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
UserForm userForm = (UserForm) form;
userForm.setMessage("Inside delete user method.");
return mapping.findForward(SUCCESS);
}
}
Код: Выделить всё
public class TestDispatchAction extends DispatchAction {
/* forward name="success" path="" */
private final static String SUCCESS = "success";
/**
* This is the Struts action method called on
* http://.../actionPath?method=myAction1,
* where "method" is the value specified in element :
* ( )
*/
public ActionForward display(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
UserForm userForm = (UserForm) form;
userForm.setMessage("Inside display user method.");
return mapping.findForward(SUCCESS);
}
}
Код: Выделить всё
function submitForm() {
document.forms[0].action = "UserAction.do?methodtocall=add";
document.forms[0].submit();
}
delete
Подробнее здесь: https://stackoverflow.com/questions/611 ... atchaction