struts豆知識点

1978 ワード

1、struts 2 spring統合時のactionのクラス属性値の意味  
struts 2単独で使う時、actionはstruts 2自身で作成します.springと統合する場合、action例はspringで作成されます.これは二つの場合のstruts.xmlプロファイルの僅かな違いをもたらします.
もし:LoginnActionはカバンcn.edu.jlu.cs.actionの中にあります.
a.struts 2単独で使用する場合、actionのクラス属性はLoginationの全パス名であり、以下の通りである.
<action name="login" class="cn.edu.jlu.cs.action.LoginAction">

           <result name="studentSuccess">

                /student/studentindex.jsp

           </result>
       b.struts 2とspringを統合する場合、class属性はspringのaplication Contact.xmlに配置されるbeanのid属性値です.
//struts.xml
               ...

<action name="login" class="LoginAction">
           <result name="studentSuccess">
                /student/studentindex.jsp
           </result>
               ...

----------------------------------------------------------------------------------------

//applicationContext.xml
               ...
<bean id="LoginAction" class="cn.edu.jlu.cs.action.LoginAction" />
2、struts 2のognl言語では、ルート以外のオブジェクト属性にアクセスします.例えば、〹session.msg表現は、Struts 2の値スタックがルートオブジェクトとみなされているため、他のルート以外のオブジェクトにアクセスする場合は、プレフィックスを追加する必要があります.実际には、29616;相当于ActContect text.get Conttext();session.msg表現は、アクションContect.get Controtext().get Session().get Attribute("msg")に相当します. 
3、struts 2がaplication、session、requestを獲得する方法
// アクションContectのインスタンスを取得して、Servletにアクセスします. API           アクションテキスト ctx = アクションContect.get Conttext();           // アプリケーションを保存           ctx.getApple().put(msg) 「appication情報」);           // 保存セッション           ctx.get Session().put("msg" 「seession情報」)           // request情報を保存します           HttpServlet Request request = ServletAction Contect.get Request()           request.set Attribute(「msg」) 「request情報」)4、strutsは表現層の枠組みであり、springは業務層の枠組みであり、hibernateは持久層の枠組みである.
5、struts 2はwebwork 2に由来し、struts 1.xとは全く互換性がない.