您的位置:首页 > 编程语言 > Java开发

【JavaWeb Structs2学习】 result设置以及默认Action设置

2016-01-21 00:03 363 查看
默认Action设置

在Structs2.xml里面写

<package name="test" namespace="/" extends="struts-default">
<default-action-ref name="hello"></default-action-ref>
<!-- 定义默认的Action -->
<action name="hello">
<result>
/Hello.jsp
</result>
</action>


里面的<default-action-ref name="hello"></default-action-ref> 默认action就是hello

result设置

result 的类型有 

1.dispatcher(不设置则大多数为这种类型) 服务器可跳转到JSP,html

2.redirect 服务器可跳转到JSP,html

3.chain 服务器可跳转到别的Action里面

我们以例子chain为例子

<action name="hello">
<result>
/Hello.jsp
</result>
</action>
<action name="go_hello">
<result type="chain">
<param name="actionName">hello</param>
<param name="namespace">/</param>
</result>
</action>


在浏览器打go_hello即可
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  JavaWeb