Created
January 9, 2011 14:11
-
-
Save taka2/771714 to your computer and use it in GitHub Desktop.
struts-config.xmlからアクション一覧を抽出
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="ISO-8859-1" ?> | |
| <!-- $Id: struts-config.xml,v 1.1.1.1 2003/08/12 14:45:44 matsu Exp $ --> | |
| <!DOCTYPE struts-config PUBLIC | |
| "-//Apache Software Foundation//DTD Struts Configuration 1.0//EN" | |
| "http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd"> | |
| <!-- | |
| コメントに対する注 | |
| 私がDTDにざっと目を通して書いたものなので,誤りがあったらごめんなさい. | |
| 「書かなくてもよい」とあるのは「書かなくても妥当な文書である」という意味である. | |
| Deprecatedは「あの」Deprecated.(おそらく全ての場合)書いても無視される. | |
| --> | |
| <struts-config> | |
| <!-- | |
| この要素の内容に要素form-beanを0個以上書く | |
| 要素名 form-beans | |
| 属性 id 書かなくてもよい | |
| type Deprecated | |
| --> | |
| <form-beans> | |
| <!-- | |
| ActionFormBeanの定義 | |
| 要素名 form-bean | |
| 属性 id 書かなくてもよい | |
| classname 書かなくてもよい. | |
| ActionFromBeanクラスの完全修飾名. | |
| 属性typeとの違いがよくわからん.初期化に関係か? | |
| name ActionFormBeanの論理名 | |
| type ActionFormBeanクラスの完全修飾名 | |
| --> | |
| <form-bean name="Type1Form" | |
| type="matsu.struts.sample.Type1Form"/> | |
| <form-bean name="Type2Form" | |
| type="matsu.struts.sample.Type2Form"/> | |
| </form-beans> | |
| <!-- | |
| この要素の内容に要素forwardを0個以上書く. | |
| 要素actionの内容に書くforwardとはscopeが違う. | |
| つまり,要素actionの内容に書いたforwardは | |
| そのActionのActionクラスからしか参照できないが, | |
| 要素global-forwardsの内容に書いたforwardは | |
| どのActionのActionクラスからも参照できる. | |
| 要素名 global-forwards | |
| 属性 id 書かなくてもよい | |
| type Deprecated | |
| --> | |
| <global-forwards> | |
| <!-- | |
| 要素名 forward | |
| 属性 id 書かなくてもよい | |
| className 書かなくてもよい. | |
| ActionForwardクラスの完全修飾名 | |
| name forwardの論理名.(必須) | |
| この名前はActionクラスにおいてforwardを指定するときに参照される. | |
| もっと直接的にいうと,この名前はActionクラスのコードにハードコードされる. | |
| (詳細は別ページで). | |
| path forwardするURI.(必須) | |
| redirect 書かなくてもよい. | |
| この属性はtrue,false,yes,noのいずれかの値をとる. | |
| trueならsendRedirect()でフォワードできる. | |
| falseならRequestDispathcer.forward()でフォワードできる. | |
| --> | |
| <forward name="globalForward1" path="/GlobalType1.jsp"/> | |
| <forward name="globalForward2" path="/GlobalType2.jsp"/> | |
| </global-forwards> | |
| <!-- | |
| この要素の内容に0個以上の要素actionを書く | |
| 要素名 id 書かなくてもよい | |
| type 書かなくてもよい. | |
| ActionMappingクラスの完全修飾名 | |
| --> | |
| <action-mappings> | |
| <!-- | |
| アクション.リクエストされたURIからActionへのマッピングを記述する. | |
| この要素の内容には0個以上の要素forwardがある(他にもset-propertyなどの要素がある). | |
| 要素名 action | |
| 属性 pathのみが必須.他は書かなくてもよい. | |
| forwardかtypeかincludeのうちどれか一つは書く必要がある. | |
| id ? | |
| attribute このActionで使用するActionFormBeanの属性. | |
| className ActionMappingクラスの完全修飾名 | |
| forward このActionへのリクエストを実行する. | |
| ServletかJSPへのContextにおける相対パス. | |
| include typeで指定されるActionをインスタンス化して呼ぶかわりに | |
| 実行するSevletやJSPへのContextにおける相対パスを書く. | |
| input 認証エラーが発生したときの入力フォーム画面. | |
| nameを指定しないと記述できない. | |
| nameを指定して認証エラーが発生したときは必須 | |
| nameを指定して認証エラーが発生しないときは,Optional | |
| name このActionに関連づけられるActionFormBeanの名前 | |
| (要素form-beanのどれかの属性nameと一致する). | |
| path /で始まるContext内でのこのActionの相対パス | |
| parameter 汎用目的で使用されるActionのパラメータ. | |
| prefix nameが指定されていないと指定できない. | |
| ActionFormBeanのパラメータ名のprefix. | |
| scope ActionFormBeanのscope. | |
| requestかsession. | |
| nameが指定されていないと使用できない. | |
| suffix nameが指定されていないと指定できない. | |
| ActionFormBeanのパラメータ名のsuffix. | |
| type このActionを処理するActionクラスの完全修飾名. | |
| forwardかincludeがないときに必要. | |
| unknown このWebアプリケーションのデフォルトのActionにしたいときに | |
| trueにする.要素Actionの中で一つだけtrueにすることができる. | |
| validate このActionを実行すう前にActionFormBeanの | |
| validate()を呼び出したいならtrueにする. | |
| 逆に呼び出したくないならtrueにする. | |
| --> | |
| <action path="/Action1" | |
| type="matsu.struts.sample.Action1" | |
| name="Type1Form"> | |
| <forward name="localForward1" path="/LocalType1.jsp" /> | |
| </action> | |
| <action path="/Action2" | |
| type="matsu.struts.sample.Action2" | |
| name="Type2Form"> | |
| <forward name="localForward2" path="/LocalType2.jsp" /> | |
| </action> | |
| <!-- | |
| 開発時には便利なアクション. | |
| セキュリティ上問題があるので, | |
| 本番時にはコメントアウトする. | |
| --> | |
| <action path="/admin/addFormBean" | |
| type="org.apache.struts.actions.AddFormBeanAction"/> | |
| <action path="/admin/addForward" | |
| type="org.apache.struts.actions.AddForwardAction"/> | |
| <action path="/admin/addMapping" | |
| type="org.apache.struts.actions.AddMappingAction"/> | |
| <action path="/admin/reload" | |
| type="org.apache.struts.actions.ReloadAction"/> | |
| <action path="/admin/removeFormBean" | |
| type="org.apache.struts.actions.RemoveFormBeanAction"/> | |
| <action path="/admin/removeForward" | |
| type="org.apache.struts.actions.RemoveForwardAction"/> | |
| <action path="/admin/removeMapping" | |
| type="org.apache.struts.actions.RemoveMappingAction"/> | |
| </action-mappings> | |
| </struts-config> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require "rexml/document" | |
| puts '"name","type","path"' | |
| doc = REXML::Document.new File.open("struts-config.xml") | |
| doc.elements["/struts-config/action-mappings"].each { |elem| | |
| if elem.node_type == :element | |
| actionName = elem.attributes["name"] | |
| actionType = elem.attributes["type"] | |
| actionPath = elem.attributes["path"] | |
| puts "\"#{actionName}\",\"#{actionType}\",\"#{actionPath}\"" | |
| end | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment