値JSPによって作用するための2つの支柱フレームワークを学びます

アクション

HttpServletRequestを、HttpSessionの和のServletContext

Struts2の3つのMapオブジェクトを使用してこのパッケージには、我々はデータにアクセスするためのMapオブジェクトを使用することができます。

するactionContextするactionContext = ActionContext.getContext()。

// GET HttpServletRequestの 
            地図<文字列、オブジェクト>要求=(マップ)するactionContext。取得" 要求を" ); 
            request.put(要求しています)。// GETのHttpSession
             // 地図の<string、オブジェクト>セッション=(マップ)actionContext.get( "セッション"); 
            地図<文字列、オブジェクト>セッション= actionContext.getSession(); 
            session.put(" B ""
                    
            " ); 
                    
            // 取得するServletContext
             // 地図の<string、オブジェクト>アプリケーション=(マップ)actionContext.get("アプリケーション"); 
            地図<文字列、オブジェクト>アプリケーション= actionContext.getApplication(); 
            application.put(" C "" Cアプリケーションである"); 

JSP界面
$ {} 
$ {B} 
$ {C} 

或则request.getAttribute(" " ); 
session.getAttribute(" B); 
application.getAttribute(" C )。

 

おすすめ

転載: www.cnblogs.com/zlj843767688/p/12626906.html