当前位置: 代码迷 >> Web前端 >> action配备的默认值,视图的各种转发类型
  详细解决方案

action配备的默认值,视图的各种转发类型

热度:79   发布时间:2012-11-03 10:57:44.0
action配置的默认值,视图的各种转发类型

一.Action配置的各项默认值:

		<!-- action配置的各项默认值 
			class默认为ActionSupport
			method默认为action中的execute()方法
		-->
		<action name="xxx" class="com.opensymphony.xwork2.ActionSupport" method="execute">
			<!-- result配置中的默认值
				name属性默认为"success" 
				type属性默认为dispatcher,即内部请求转发方式-->
			<result name="success" type="dispatcher">/WEB-INF/page/hello.jsp</result>
		</action>
?

二.result的类型(视图的转发类型)

dispatcher:内部请求转发方式(默认值)

redirect:重定向(此时重定向的视图页面不能位于WEB-INF目录下,一定要浏览器能够直接访问的页面)

<result name="success" type="redirect">/hello.jsp</result>?

redirectAction:重定向到某个action

<!-- 如果Action位于统一个包下 -->
<result type="redirectAction">actionName</result>
<!-- 如果Action位于不同的包下 -->
<result type="redirectAction">
	<param name="actionName">actionName</param>
	<param name="namespace">namespace</param>
</result>
??

?

  相关解决方案