<action>
标签的include 和 forward属性有什么区别吗?
我两个属性都测试了一下,执行结果是一样的。
都没有进action类,好像都是过了ActionForm后就直接奔JSP去了。。

解决方案 »

  1.   

    include 是去而复返,继续本程序的执行forward 是一去不复返了! 再也不回来了!
      

  2.   

    forward是转向,重新打开连接,request不会带过去。
      

  3.   

    从执行结果来看不是这样的,就算我用include
    它也并没有进Action,而是直接跑到JSP里去。
      

  4.   

    不知道楼主说的include是jsp的指令还是动作,指令的话,也可以理解为就是一个整体的东西,只不过被包含的东西可能写在另外的地方了,编译的时候,将先合并文件,再进行编译。而如果是动作的话,被包含的servlet将不对包含页面传递过来的,response对象改变产生作用,就是里面即使有response.sendRedict("/index.jsp")也是没有作用的,会被忽略掉,因此最后回给浏览器的响应对象还是之前的response对象,forward方法是将将请求对象和响应对象在服务器端一同转给了另外一个资源(servlet),这个servlet可以对响应对象做修改,并最终传递给浏览器。
      

  5.   

    别理解错了,我没说JSP的include和forward
    我说的是Struts的<action>标签的include 和 forward属性!!!
      

  6.   

    别理解错了,我没说JSP的include和forward 
    我说的是Struts的 <action>标签的include 和 forward属性!!!
      

  7.   

    servlet1中include另外一个servlet2,会计算servlet2,计算后不运行servlet2的跳转,而是回到servlet1,最终转向servlet1决定,servlet2中的request和response对象中存储的数据被和并到servlet1的request和response对象中。标签应该也是这个样子.
      

  8.   

    include 是引入文件
    forward 是重定向
    好像本来就没什么关系吧~~~~
    老紫竹解释的应该是forward 和sendRedirect吧~~~~
    混乱中~难道是我弄错拉~~~
      

  9.   

    struts-config_1_3.dtd 中的权威解释:     forward         Module-relative path of the servlet or other resource that
                         will process this request, instead of the Action class
                         specified by "type".  The path WILL NOT be processed
                         through the "forwardPattern" attribute that is configured
                         on the "controller" element for this module.
                         Exactly one of "forward", "include", or "type" must be
                         specified.     include         Module-relative path of the servlet or other resource that
                         will process this request, instead of the Action class
                         specified by "type".  The path WILL NOT be processed
                         through the "forwardPattern" attribute that is configured
                         on the "controller" element for this module.
                         Exactly one of "forward", "include", or "type" must be
                         specified.
    “instead of the Action class specified by "type".” 关键在这句,如果有 forward 或 include 属性,那 struts 会忽略 path 属性,设了也白设。
      

  10.   

    23楼更正:那 struts 会忽略 type 属性,设了也白设。
      

  11.   

    区别在 forward 前会清空缓存,include 不会。
      

  12.   

    此回复为自动发出,仅用于显示而已,并无任何其他特殊作用
    楼主【joejoe1991】截止到2008-07-02 09:41:09的历史汇总数据(不包括此帖):
    发帖的总数量:221                      发帖的总分数:6070                     
    结贴的总数量:174                      结贴的总分数:5224                     
    无满意结贴数:4                        无满意结贴分:130                      
    未结的帖子数:47                       未结的总分数:846                      
    结贴的百分比:78.73 %               结分的百分比:86.06 %                  
    无满意结贴率:2.30  %               无满意结分率:2.49  %                  
    楼主加油