2012/8/4Action中result的各种转发类型

①在struts2中提供了多种result类型,常用的类型有:dispatcher(默认值)、redirect、redirectAction、plainText

②在result中还可以使用${属性名}表达式访问action中的属性,表达式里的属性名对应action中的属性。如下:

<result name="success" type="redirect">/employeeAdd.jsp?username=${username}</result>

③下面是redirectAction结果类型的例子,如果重定向的action在同一个包下:

<result type="redirectAction">helloworld</result>

④如果重定向的action在别的命名空间下:

<result type="redirectAcion">

    <param name="actionName">helloworld</param>

    <param name="namespace">/test<param>

<result>

⑤plaintext显示原始文件内容,例如:当我们需要显示jsp文件源代码的时候,我们可以使用此类型。

<action name="plainText">
   <result type="plainText">
    <param name="location">/index.jsp</param>
    <param name="charSet">UTF-8</param>  <!-- 指定读取文件的编码 -->
   </result>
  </action> 

原文地址:https://www.cnblogs.com/howlaa/p/2623285.html