| 目次 |
|---|
|
・アクションクラスでのエラー表示 ・JSPでのエラー表示 |
public class dispDetailAction extends Action{
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest req,
HttpServletResponse res) throws Exception{
ActionErrors errors = new ActionErrors();
// ロジック
if(!errors.isEmpty()){
errors.add(ActionMessages.GLOBAL_MESSAGE,ActionMessage("msg1");
saveErrors(req,errors);
return mapping.findForward("error");
}
return mapping.findForward("success");
}
エラーメッセージはstruts-config.xmlで指定しているメッセージリソースから取得します。上記例では、キーはmsg1です。