Struts: вызов метода Dispatch Action из другого DispatchAction.JAVA

Программисты JAVA общаются здесь
Ответить
Anonymous
 Struts: вызов метода Dispatch Action из другого DispatchAction.

Сообщение Anonymous »

Я хочу вызвать метод диспетчерского действия из другого действия диспетчеризации.
Я хочу, чтобы при нажатии на обновление или удаление «Пользовательский метод внутреннего отображения» отображался на моем 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);
}

}
Страница JSP

Код: Выделить всё



function submitForm() {
document.forms[0].action = "UserAction.do?methodtocall=add";
document.forms[0].submit();
}








delete




спасибо

Подробнее здесь: https://stackoverflow.com/questions/611 ... atchaction
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «JAVA»