JAEE學(xué)習(xí)筆記(25)Struts2(1)

struts2框架

目錄

1.介紹struts2

2.關(guān)于struts2配置(關(guān)于Action配置)---重點(diǎn)

3.關(guān)于struts2結(jié)果類型

4.struts2處理請(qǐng)求參數(shù)---重點(diǎn)

5.struts2的類型轉(zhuǎn)換

6.struts2的校驗(yàn)

7.struts2國(guó)際化

8.struts2攔截器----重點(diǎn)

9.struts2文件上傳與下載

10.struts2中ognl與valuestack----重點(diǎn)

11.ognl與valuestatck-----重點(diǎn)

12.struts2中的防止表單重復(fù)提交

13.struts2中ajax插件.

14.練習(xí)

=======================================================

1.介紹struts2框架
    問題:什么是框架虾标,框架有什么用?
        框架 是 實(shí)現(xiàn)部分功能的代碼 (半成品),使用框架簡(jiǎn)化企業(yè)級(jí)軟件開發(fā) ,提高開發(fā)效率宙地。
        學(xué)習(xí)框架 搂蜓,清楚的知道框架能做什么? 還有哪些工作需要自己編碼實(shí)現(xiàn) 由蘑? 
        
    問題:什么是struts2框架闽寡,它有什么用?
        Struts 2是Struts的下一代產(chǎn)品,是在 struts 1和WebWork的技術(shù)基礎(chǔ)上進(jìn)行了合并的全新的Struts 2框架尼酿。
        其全新的Struts 2的體系結(jié)構(gòu)與Struts 1的體系結(jié)構(gòu)差別巨大爷狈。Struts 2以WebWork為核心
        struts2=struts1+webwork;            
        struts2框架是apache產(chǎn)品。         
        struts2是一個(gè)標(biāo)準(zhǔn)的mvc框架裳擎。  javaweb中的model2模式就是一個(gè)mvc模式涎永。  model2=servlet+jsp+javaBean           
        struts2框架是在javaweb開發(fā)中使用的。           
        使用struts2框架鹿响,可以簡(jiǎn)化我們的web開發(fā)羡微,并且降低程序的耦合度。
        
    類似于struts2框架的產(chǎn)品 :
        struts1  webwork  jsf  springmvc
        
        ssh---struts2 spring hibernate
        ssi---springmvc spring ibatis
        
    XWork---它是webwork核心
    Xwork提供了很多核心功能:前端攔截機(jī)(interceptor)惶我,運(yùn)行時(shí)表單屬性驗(yàn)證妈倔,類型轉(zhuǎn)換,
    強(qiáng)大的表達(dá)式語言(OGNL – the Object Graph Navigation Language)绸贡,
    IoC(Inversion of Control反轉(zhuǎn)控制)容器等    
-----------------------------------------------------------------------------
struts2快速入門:
    index.jsp------>HelloServlet-------->hello.jsp  web開發(fā)流程.
    index.jsp------>HelloAction--------->hello.jsp  struts2流程
    
    1.導(dǎo)入jar包
        下載struts2的jar包  struts-2.3.15.1-all 版本.
        
        struts2的目錄結(jié)構(gòu):
            apps: 例子程序
            docs:文檔
            lib:struts2框架所應(yīng)用的jar以及插件包               
            src:源代碼  
                core  它是struts2的源代碼
                xwork-core struts2底層使用了xwork,xwork的源代碼
                
        注意:在struts2開發(fā)盯蝴,一般情況下最少導(dǎo)入的jar包,去apps下的struts2-blank示例程序中copy
    
    2.創(chuàng)建index.jsp頁面
      創(chuàng)建hello.jsp頁面

    3.對(duì)struts2框架進(jìn)行配置
        1.web.xml文件中配置前端控制器(核心控制器)-----就是一個(gè)Filter
            目的:是為了讓struts2框架可以運(yùn)行听怕。
             <filter>
                <filter-name>struts2</filter-name>
                <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
            </filter>

            <filter-mapping>
                <filter-name>struts2</filter-name>
                <url-pattern>/*</url-pattern>
            </filter-mapping>
            
        2.創(chuàng)建一個(gè)struts.xml配置文件 ,這個(gè)是struts2框架配置文件捧挺。
            目的:是為了struts2框架流程可以執(zhí)行。
            
            名稱:struts.xml
            位置:src下(classes下)
            
    4.創(chuàng)建一個(gè)HelloAction類
        要求尿瞭,在HelloAction類中創(chuàng)建一個(gè)返回值是String類型的方法闽烙,注意,無參數(shù)声搁。
        public String say(){
            return "good";
        }
        
    5.在struts.xml文件中配置HelloAction
        
        <package name="default" namespace="/" extends="struts-default">
            <action name="hello" class="cn.itcast.action.HelloAction"
                method="say">
                <result name="good">/hello.jsp</result>
            </action>
        </package>
        
    6.在index.jsp中添加連接黑竞,測(cè)試
        <a href="${pageContext.request.contextPath}/hello">第一次使用struts2</a>
        在地址欄中輸入:http://localhost/struts2_day01/index.jsp  訪問連接,就可以看到
        HelloAction類中的say方法執(zhí)行了酥艳,也跳轉(zhuǎn)到了hello.jsp

--------------------------------------------------------------------------
模仿struts2流程完成入門程序:
    index.jsp
    hello.jsp
    HelloAction
    struts.xml
-----------------
1.創(chuàng)建一個(gè)Filter----StrutsFilter
2.在web.xml文件中配置StrutsFilter
    <filter>
        <filter-name>struts</filter-name>
        <filter-class>cn.itcast.filter.StrutsFilter</filter-class>
    </filter>

    <filter-mapping>
        <filter-name>struts</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
3.在StrutsFilter中完成攔截操作摊溶,并訪問Action中的方法,跳轉(zhuǎn)到hello.jsp頁面操作.
    
        // 2.1 得到請(qǐng)求資源路徑
        String uri = request.getRequestURI();
        String contextPath = request.getContextPath();
        String path = uri.substring(contextPath.length() + 1);

        // System.out.println(path); // hello

        // 2.2 使用path去struts.xml文件中查找某一個(gè)<action name=path>這個(gè)標(biāo)簽
        SAXReader reader = new SAXReader();
        // 得到struts.xml文件的document對(duì)象充石。
        Document document = reader.read(new File(this.getClass()
                .getResource("/struts.xml").getPath()));

        Element actionElement = (Element) document
                .selectSingleNode("http://action[@name='" + path + "']"); // 查找<action
                                                                        // name='hello'>這樣的標(biāo)簽

        if (actionElement != null) {
            // 得到<action>標(biāo)簽上的class屬性以及method屬性
            String className = actionElement.attributeValue("class"); // 得到了action類的名稱
            String methodName = actionElement.attributeValue("method");// 得到action類中的方法名稱莫换。

            // 2.3通過反射,得到Class對(duì)象,得到Method對(duì)象
            Class actionClass = Class.forName(className);
            Method method = actionClass.getDeclaredMethod(methodName);

            // 2.4 讓method執(zhí)行.
            String returnValue = (String) method.invoke(actionClass
                    .newInstance()); // 是讓action類中的方法執(zhí)行拉岁,并獲取方法的返回值坷剧。

            // 2.5
            // 使用returnValue去action下查找其子元素result的name屬性值喊暖,與returnValue做對(duì)比惫企。
            Element resultElement = actionElement.element("result");
            String nameValue = resultElement.attributeValue("name");

            if (returnValue.equals(nameValue)) {
                // 2.6得到了要跳轉(zhuǎn)的路徑。
                String skipPath = resultElement.getText();

                // System.out.println(skipPath);

                request.getRequestDispatcher(skipPath).forward(request,
                        response);
                return;
            }
        }

=======================================================

struts2的流程分析以及工具配置
1.流程分析
    請(qǐng)求 ---- StrutsPrepareAndExecuteFilter 核心控制器 ----- Interceptors 攔截器(實(shí)現(xiàn)代碼功能 ) ----- Action 的execute --- 結(jié)果頁面 Result 
    * 攔截器 在 struts-default.xml定義
    * 執(zhí)行攔截器 是 defaultStack 中引用攔截器 

    ---- 通過源代碼級(jí)別斷點(diǎn)調(diào)試陵叽,證明攔截器是執(zhí)行 

            
2.關(guān)于手動(dòng)配置struts.xml文件中提示操作
    
     如果安裝Aptana編輯器 狞尔,請(qǐng)不要用Aptana自帶xml編輯器 編寫struts2配置文件 
     struts.xml提示來自于 DTD約束, 
        <!DOCTYPE struts PUBLIC
        "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
        "http://struts.apache.org/dtds/struts-2.3.dtd">
        如果可以上網(wǎng)巩掺,自動(dòng)緩存dtd偏序,提供提示功能
        如果不能上網(wǎng),也可以配置本地DTD提示 

    *** 導(dǎo)入DTD時(shí)胖替,應(yīng)該和配置DTD版本一致 
    
3.關(guān)聯(lián)struts2源文件
    如果是com.opensymphony.xxx   在xwork-core下
    如果是org.apache.struts2     在core下
    
    
4.使用插件  struts2-config-browser-plugin-2.3.15.1
    提供在瀏覽器中查看 struts2 配置加載情況 

    將解壓struts2/lib/struts2-config-browser-plugin-2.3.7.jar 復(fù)制WEB-INF/lib下 

    訪問 http://localhost/struts2_day01/config-browser/index.action 查看 struts2配置加載情況

=========================================================

struts2配置(重點(diǎn))
1.struts2配置文件加載順序
    struts2框架要能執(zhí)行研儒,必須先加載StrutsPrepareAndExecuteFilter.
    
    在StrutsPrepareAndExecuteFilter的init方法中對(duì)Dispatcher進(jìn)行了初始化.
    在Dispatcher類中定義的init方法內(nèi)就描述了struts2配置文件加載的順序
    
        init_DefaultProperties(); // [1]   ----------  org/apache/struts2/default.properties 
        init_TraditionalXmlConfigurations(); // [2]  --- struts-default.xml,struts-plugin.xml,struts.xml
        init_LegacyStrutsProperties(); // [3] --- 自定義struts.properties 
        init_CustomConfigurationProviders(); // [5]  ----- 自定義配置提供
        init_FilterInitParameters() ; // [6] ----- web.xml 
        init_AliasStandardObjects() ; // [7] ---- Bean加載 
        
        1.default.properties文件
            作用:定義了struts2框架中所有常量
            位置: org/apache/struts2/default.properties 
            
        2.struts-default.xml
            作用:配置了bean,interceptor,result等。
            位置:在struts的core核心jar包.
            
          struts-plugin.xml
            它是struts2框架中所使用的插件的配置文件独令。
          struts.xml              
            我們使struts2所使用的配置文件端朵。
                
        3.自定義的struts.properties
            就是可以自定義常量。
            
        4.web.xml
        
        在開發(fā)中燃箭,后加載文件中的配置會(huì)將先加載文件中的配置覆蓋冲呢。
        
        default.properties
        struts-default.xml
        struts.xml
            
-----------------------------------------------------------------------         
2.關(guān)于Action的配置
    
    1.<package>  作用:是用于聲明一個(gè)包。用于管理action遍膜。
        1.name     它用于聲明一個(gè)包名碗硬,包名不能重復(fù)瓤湘,也就是它是唯一的瓢颅。 
        2.namespace  它與action標(biāo)簽的name屬性合并確定了一個(gè)唯一訪問action的路徑。
        3.extends  它代表繼承的包名弛说。
        4.abstrace 它可以取值為true/false,如果為true,代表這個(gè)包是用于被繼承的挽懦。
    2<action>  用于聲明 一個(gè)action
        1.name  就是action的一個(gè)名稱,它是唯一的(在同包內(nèi)) 它與package中的namespace確定了訪問action的路徑木人。
        2.class Action類的全名
        3.method 要訪問的Action類中的方法的名稱,方法無參數(shù) 信柿,返回值為String.
    3.<result> 用于確定返回結(jié)果類型
        1.name  它與action中的方法返回值做對(duì)比,確定跳轉(zhuǎn)路徑醒第。
        
    關(guān)于action配置其它細(xì)節(jié):
        1.關(guān)于默認(rèn)值問題
            <package namespace="默認(rèn)值"> namespace的默認(rèn)值是""
            <action class="默認(rèn)值"  method="默認(rèn)值">
                class的默認(rèn)值是  com.opensymphony.xwork2.ActionSupport

                method的默認(rèn)值是  execute
            <result\d   X name="默認(rèn)值"> name的默認(rèn)值是 "success"       

        2.關(guān)于訪問action的路徑問題   
            現(xiàn)在的action的配置是:
            <package name="default" namespace="/" extends="struts-default">
                <action name="hello" class="cn.itcast.action.DefaultAction">
                    <result>/hello.jsp</result>
                </action>
            </package>
            
            當(dāng)我們輸入:
            http://localhost/struts2_day01_2/a/b/c/hello
            也訪問到了action渔嚷。
            
            原因:struts2中的action被訪問時(shí),它會(huì)首先查找
             1.namespace="/a/b/c"  action的name=hello  沒有.
             2.namespace="/a/b     action的name=hello  沒有
             3.namespace="/a"      action的name=hello  沒有
             4.namespace="/"        action的name=hello  查找到了.
             
             如果最后也查找不到稠曼,會(huì)報(bào)404錯(cuò)誤.
        
        3.默認(rèn)的action形病。
            作用:處理其它action處理不了的路徑。
            
            <default-action-ref name="action的名稱" />
            配置了這個(gè),當(dāng)訪問的路徑漠吻,其它的action處理不了時(shí)量瓜,就會(huì)執(zhí)行name指定的名稱的action。
            
        4.action的默認(rèn)處理類
            在action配置時(shí)途乃,如果class不寫绍傲。默認(rèn)情況下是 com.opensymphony.xwork2.ActionSupport。
            
            <default-class-ref class="cn.itcast.action.DefaultAction"/>
            如果設(shè)置了耍共,那么在當(dāng)前包下烫饼,默認(rèn)處理action請(qǐng)的的處理類就為class指定的類。
            
---------------------------------------------------------------------------
關(guān)于常量配置
    default.properties 它聲明了struts中的常量试读。
    
    問題:人為設(shè)置常量枫弟,可以在哪些位置設(shè)置 ?
        1.struts.xml(應(yīng)用最多)
            <constant name="常量名稱" value="常量值"></constant>
        2.struts.properties(基本不使用)          
        3.web.xml(了解)
            配置常量鹏往,是使用StrutsPrepareAndExecuteFilter的初始化參數(shù)來配置的.
            <init-param>
                <param-name>struts.action.extension</param-name>
                <param-value>do,,</param-value>
            </init-param>
        
    常用常量
        struts.action.extension=action,, 
        這個(gè)常量用于指定strus2框架默認(rèn)攔截的后綴名.
        
        <constant name="struts.i18n.encoding" value="UTF-8"/>  
            相當(dāng)于request.setCharacterEncoding("UTF-8"); 解決post請(qǐng)求亂碼 
            
        <constant name="struts.serve.static.browserCache" value="false"/> 
            false不緩存淡诗,true瀏覽器會(huì)緩存靜態(tài)內(nèi)容,產(chǎn)品環(huán)境設(shè)置true伊履、開發(fā)環(huán)境設(shè)置false  
        
        <constant name="struts.devMode" value="true" />  
            提供詳細(xì)報(bào)錯(cuò)頁面韩容,修改struts.xml后不需要重啟服務(wù)器 (要求)
  ----------------------------------------------------------------------------
struts.xml文件的分離:

    目的:就是為了閱讀方便√破伲可以讓一個(gè)模塊一個(gè)配置文件群凶,在struts.xml文件中通過
    <include file="test.xml"/>導(dǎo)入其它的配置文件。

===========================================================

Action
1.關(guān)于Action類的創(chuàng)建方式介紹:
    有三種方式
    1.創(chuàng)建一個(gè)POJO類.
        簡(jiǎn)單的Java對(duì)象(Plain Old Java Objects)
        指的是沒有實(shí)現(xiàn)任何接口哄辣,沒有繼承任何父類(除了Object)
        
        優(yōu)點(diǎn):無耦合请梢。
        缺點(diǎn):所以工作都要自己實(shí)現(xiàn)。
        
        在struts2框架底層是通過反射來操作:
            * struts2框架 讀取struts.xml 獲得 完整Action類名 
            * obj = Class.forName("完整類名").newInstance();
            * Method m = Class.forName("完整類名").getMethod("execute");  m.invoke(obj); 通過反射 執(zhí)行 execute方法

    2.創(chuàng)建一個(gè)類力穗,實(shí)現(xiàn)Action接口.  com.opensymphony.xwork2.Action
        
        優(yōu)點(diǎn):耦合低毅弧。提供了五種結(jié)果視圖,定義了一個(gè)行為方法当窗。
        缺點(diǎn):所以工作都要自己實(shí)現(xiàn)够坐。
        
        public static final String SUCCESS = "success";  // 數(shù)據(jù)處理成功 (成功頁面)
        public static final String NONE = "none";  // 頁面不跳轉(zhuǎn)  return null; 效果一樣
        public static final String ERROR = "error";  // 數(shù)據(jù)處理發(fā)送錯(cuò)誤 (錯(cuò)誤頁面)
        public static final String INPUT = "input"; // 用戶輸入數(shù)據(jù)有誤,通常用于表單數(shù)據(jù)校驗(yàn) (輸入頁面)
        public static final String LOGIN = "login"; // 主要權(quán)限認(rèn)證 (登陸頁面)

    3.創(chuàng)建一個(gè)類崖面,繼承自ActionSupport類.  com.opensymphony.xwork2.ActionSupport
        ActionSupport類實(shí)現(xiàn)了Action接口元咙。
        
        優(yōu)點(diǎn):表單校驗(yàn)、錯(cuò)誤信息設(shè)置巫员、讀取國(guó)際化信息 三個(gè)功能都支持.
        缺點(diǎn):耦合度高庶香。
        
    在開發(fā)中,第三種會(huì)使用的比較多.
--------------------------------------------------------------------------  
關(guān)于action的訪問:

    1.通過設(shè)置method的值简识,來確定訪問action類中的哪一個(gè)方法.
        <action name="book_add" class="cn.itcast.action.BookAction" method="add"></action>
        當(dāng)訪問的是book_add,這時(shí)就會(huì)調(diào)用BookAction類中的add方法赶掖。         
        <action name="book_update" class="cn.itcast.action.BookAction"  method="update"></action>
        當(dāng)訪問的是book_update,這時(shí)就會(huì)調(diào)用BookAction類中的update方法救军。
        
    2.使用通配符來簡(jiǎn)化配置
        1.在struts.xml文件中
            <action name="*_*" class="cn.itcast.action.{1}Action" method="{2}"></action>
        2.在jsp頁面上
            book.jsp
                <a href="${pageContext.request.contextPath}/Book_add">book add</a><br>
                <a href="${pageContext.request.contextPath}/Book_update">book update</a><br>
                <a href="${pageContext.request.contextPath}/Book_delete">book delete</a><br>
                <a href="${pageContext.request.contextPath}/Book_search">book search</a><br>
            product.jsp
                <a href="${pageContext.request.contextPath}/Product_add">product add</a><br>
                <a href="${pageContext.request.contextPath}/Product_update">product update</a><br>
                <a href="${pageContext.request.contextPath}/Product_delete">product delete</a><br>
                <a href="${pageContext.request.contextPath}/Product_search">product search</a><br>
            
            當(dāng)訪問book add時(shí),這時(shí)的路徑是  Book_add,那么對(duì)于struts.xml文件中.
            第一個(gè)星就是   Book
            第二個(gè)星就是   add
            對(duì)于{1}Action---->BookAction
            對(duì)于method={2}--->method=add
            
        使用通配符來配置注意事項(xiàng):
            1.必須定義一個(gè)統(tǒng)一的命名規(guī)范倘零。
            2.不建議使用過多的通配符唱遭,閱讀不方便。
    ----------------------------------------------
    3.動(dòng)態(tài)方法調(diào)用    (了解)
        在struts.xml文件中
             <action name="book" class="cn.itcast.action.BookAction"></action>
        訪問時(shí)路徑: http://localhost/struts2_day01_2/book!add
            就訪問到了BookAction類中的add方法呈驶。
        
        對(duì)于book!add 這就是動(dòng)態(tài)方法調(diào)用拷泽。
        
        注意:struts2框架支持動(dòng)態(tài)方法調(diào)用,是因?yàn)樵赿efault.properties配置文件中設(shè)置了
             動(dòng)態(tài)方法調(diào)用為true.

            struts.enable.DynamicMethodInvocation = true

============================================================

在struts2框架中獲取servlet api
對(duì)于struts2框架袖瞻,不建議直接使用servlet api;

在struts2中獲取servlet api有三種方式:
    1.通過ActionContext來獲取
        1.獲取一個(gè)ActionContext對(duì)象司致。
            ActionContext context=ActionContext.getContext();
        2.獲取servlet api
            注意:通過ActionContext獲取的不是真正的Servlet api,而是一個(gè)Map集合。
            
            1.context.getApplication()
            2.context.getSession()
            3.context.getParameter();---得到的就相當(dāng)于request.getParameterMap()
            4.context.put(String,Object) 相當(dāng)于request.setAttribute(String,String);
                
    
    2.注入方式獲取(這種方式是真正的獲取到了servlet api)
        
        1.要求action類必須實(shí)現(xiàn)提定接口聋迎。
            ServletContextAware : 注入ServletContext對(duì)象
            ServletRequestAware :注入 request對(duì)象
            ServletResponseAware : 注入response對(duì)象

        2.重定接口中的方法脂矫。             
            private HttpServletRequest request;
        3.聲明一個(gè)web對(duì)象,使用接口中的方法的參數(shù)對(duì)聲明的web對(duì)象賦值. 
            public void setServletRequest(HttpServletRequest request) {
                this.request = request;
            }
            
        擴(kuò)展:分析其實(shí)現(xiàn):
            是使用struts2中的一個(gè)interceptor完成的.
            <interceptor name="servletConfig" class="org.apache.struts2.interceptor.ServletConfigInterceptor"/>
            
             if (action instanceof ServletRequestAware) { //判斷action是否實(shí)現(xiàn)了ServletRequestAware接口
                HttpServletRequest request = (HttpServletRequest) context.get(HTTP_REQUEST); //得到request對(duì)象.
                ((ServletRequestAware) action).setServletRequest(request);//將request對(duì)象通過action中重寫的方法注入霉晕。
            }
            
    3.通過ServletActionContext獲取.
        在ServletActionContext中方法都是static庭再。           
        getRequest();
        getResposne();
        getPageContext();

  --------------------------------------------------------------------
Result結(jié)果類型
    <result>標(biāo)簽
        1.name  與action中的method的返回值匹配,進(jìn)行跳轉(zhuǎn).
            
        2.type  作用:是用于定義跳轉(zhuǎn)方式
            
        對(duì)于type屬性它的值有以下幾種:
            在struts-default.xml文件中定義了type可以取的值
            
             <result-type name="chain" class="com.opensymphony.xwork2.ActionChainResult"/>
            <result-type name="dispatcher" class="org.apache.struts2.dispatcher.ServletDispatcherResult" default="true"/>
            <result-type name="freemarker" class="org.apache.struts2.views.freemarker.FreemarkerResult"/>
            <result-type name="httpheader" class="org.apache.struts2.dispatcher.HttpHeaderResult"/>
            <result-type name="redirect" class="org.apache.struts2.dispatcher.ServletRedirectResult"/>
            <result-type name="redirectAction" class="org.apache.struts2.dispatcher.ServletActionRedirectResult"/>
            <result-type name="stream" class="org.apache.struts2.dispatcher.StreamResult"/>
            <result-type name="velocity" class="org.apache.struts2.dispatcher.VelocityResult"/>
            <result-type name="xslt" class="org.apache.struts2.views.xslt.XSLTResult"/>
            <result-type name="plainText" class="org.apache.struts2.dispatcher.PlainTextResult" />
        
        必會(huì): chain  dispatcher  redirect redirectAction  stream
            
            dispatcher:它代表的是請(qǐng)求轉(zhuǎn)發(fā)牺堰,也是默認(rèn)值拄轻。它一般用于從action跳轉(zhuǎn)到頁面。
            chain:它也相當(dāng)于請(qǐng)求轉(zhuǎn)發(fā)伟葫。它一般情況下用于從一個(gè)action跳轉(zhuǎn)到另一個(gè)action恨搓。
            
            redirect:它代表的是重定向  它一般用于從action跳轉(zhuǎn)到頁面
            redirectAction: 它代表的是重定向  它一般用于從action跳轉(zhuǎn)另一個(gè)action。
            
            stream:代表的是服務(wù)器端返回的是一個(gè)流筏养,一般用于下載斧抱。
            
        了解: freemarker  velocity
        
-----------------------------------------------------------------------------
    局部結(jié)果頁面與全局結(jié)果頁面
         局部結(jié)果頁面 和 全局結(jié)果頁面 
        <action name="result" class="cn.itcast.struts2.demo6.ResultAction">
                    <!-- 局部結(jié)果  當(dāng)前Action使用 -->
                    <result name="success">/demo6/result.jsp</result> 
        </action>
         
        <global-results>
                    <!-- 全局結(jié)果 當(dāng)前包中 所有Action都可以用-->
                    <result name="success">/demo6/result.jsp</result>
        </global-results>
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市渐溶,隨后出現(xiàn)的幾起案子辉浦,更是在濱河造成了極大的恐慌,老刑警劉巖掌猛,帶你破解...
    沈念sama閱讀 219,188評(píng)論 6 508
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件叉趣,死亡現(xiàn)場(chǎng)離奇詭異艳丛,居然都是意外死亡,警方通過查閱死者的電腦和手機(jī)有额,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,464評(píng)論 3 395
  • 文/潘曉璐 我一進(jìn)店門竹海,熙熙樓的掌柜王于貴愁眉苦臉地迎上來慕蔚,“玉大人,你說我怎么就攤上這事斋配】嘴” “怎么了灌闺?”我有些...
    開封第一講書人閱讀 165,562評(píng)論 0 356
  • 文/不壞的土叔 我叫張陵,是天一觀的道長(zhǎng)坏瞄。 經(jīng)常有香客問我桂对,道長(zhǎng),這世上最難降的妖魔是什么鸠匀? 我笑而不...
    開封第一講書人閱讀 58,893評(píng)論 1 295
  • 正文 為了忘掉前任蕉斜,我火速辦了婚禮,結(jié)果婚禮上缀棍,老公的妹妹穿的比我還像新娘宅此。我一直安慰自己,他們只是感情好爬范,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,917評(píng)論 6 392
  • 文/花漫 我一把揭開白布父腕。 她就那樣靜靜地躺著,像睡著了一般青瀑。 火紅的嫁衣襯著肌膚如雪璧亮。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 51,708評(píng)論 1 305
  • 那天斥难,我揣著相機(jī)與錄音杜顺,去河邊找鬼。 笑死蘸炸,一個(gè)胖子當(dāng)著我的面吹牛躬络,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播搭儒,決...
    沈念sama閱讀 40,430評(píng)論 3 420
  • 文/蒼蘭香墨 我猛地睜開眼穷当,長(zhǎng)吁一口氣:“原來是場(chǎng)噩夢(mèng)啊……” “哼!你這毒婦竟也來了淹禾?” 一聲冷哼從身側(cè)響起馁菜,我...
    開封第一講書人閱讀 39,342評(píng)論 0 276
  • 序言:老撾萬榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎铃岔,沒想到半個(gè)月后汪疮,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 45,801評(píng)論 1 317
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡毁习,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,976評(píng)論 3 337
  • 正文 我和宋清朗相戀三年智嚷,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片纺且。...
    茶點(diǎn)故事閱讀 40,115評(píng)論 1 351
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡盏道,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出载碌,到底是詐尸還是另有隱情猜嘱,我是刑警寧澤衅枫,帶...
    沈念sama閱讀 35,804評(píng)論 5 346
  • 正文 年R本政府宣布,位于F島的核電站朗伶,受9級(jí)特大地震影響弦撩,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜论皆,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,458評(píng)論 3 331
  • 文/蒙蒙 一益楼、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧纯丸,春花似錦偏形、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,008評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至坠陈,卻和暖如春萨惑,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背仇矾。 一陣腳步聲響...
    開封第一講書人閱讀 33,135評(píng)論 1 272
  • 我被黑心中介騙來泰國(guó)打工庸蔼, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人贮匕。 一個(gè)月前我還...
    沈念sama閱讀 48,365評(píng)論 3 373
  • 正文 我出身青樓姐仅,卻偏偏與公主長(zhǎng)得像,于是被迫代替她去往敵國(guó)和親刻盐。 傳聞我的和親對(duì)象是個(gè)殘疾皇子掏膏,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,055評(píng)論 2 355

推薦閱讀更多精彩內(nèi)容