トップ 差分 一覧 ソース 置換 検索 ヘルプ PDF RSS ログイン

Actionクラスでのエラーメッセージ設定

エラーの設定

public ActionForward execute(
  ActionMapping mapping, ActionForm form,
  HttpServletRequest request, HttpServletResponse response) throws Exception {


       ActionMessages ms = new ActionMessages();
       ActionMessage m = new ActionMessage("key"); //MessageResourceに設定したKey
       ms.add(ActionMessages.GLOBAL_MESSAGE, m); //第1引数はエラー表示時のProperty
       saveErrors(request, ms);
       return mapping.findForward("error");

}


エラーの表示

<html:errors />
<html:errors header="false" footer="false" property="userId" />
<html:messages id="message" property="<%= org.apache.struts.action.ActionMessages.GLOBAL_MESSAGE %>">
とか。


[カテゴリ: プログラミング言語 > Servlet & Struts]

[通知用URL]



  • Hatenaブックマークに追加
  • livedoorクリップに追加
  • del.icio.usに追加
  • FC2ブックマークに追加

最終更新時間:2008年05月25日 22時55分49秒