读书人

Struts2应用开发详解-五、result中的各

发布时间: 2012-09-28 00:03:35 作者: rapoo

Struts2应用开发详解--5、result中的各种转发类型

???

??? result配置类似于struts1中的forword,但struts2中提供了更多的类型,常用类型有dispatcher(默认值)、redirect、redirectAction、plainText。

?

使用${属性名}表达是的方式访问action中的属性,表达式里的属性对应action中的属性。如下:

<result type="redirectAction">/delete.jsp?id=${id}</result>

?

redirectAction的例子,重定向的路径为同一个包下:

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

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

<result type="redirectAction">

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

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

</result>

?

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

<result name="source" type="plainText">

???? <param name="location">/*.jsp</param>?

???? <param name="charSet">UTF-8</param><!--?制定读取文件的编码 -->

</result>

?

?

读书人网 >软件架构设计

热点推荐