Struts2 result类型
1.dispatcher:服务器跳转到页面,通常来处理JSP,默认类型。
2.redirect:重定向到页面。
Action:
public String redirect() {
message = "message中有值";
return "redirect";
}
struts.xml:
<package name="chapter3" namespace="/chapter3" extends="struts-default">
<action name="redirectAction" class="chapter3.action.Chapter3Action" method="redirect">
<result name="redirect" type="redirect">/redirect.jsp</result>
</action>
</package>
注意的地方:外部中转不能带值过去,并且页面不能受保护
传参数:
<action name="redirectAction" class="chapter3.action.Chapter3Action" method="redirect">
<result name="redirect" type="redirect">/redirect.jsp?message=${message}</result>
</action>
页面:
${param.message}<br>
3.chain:服务端跳转到Action;
action
public String action2() {
message = "我是action2中设置的值";
return "action2";
}
struts.xml
<package name="chapter32" namespace="/chapter32" extends="struts-default">
<action name="action2" class="chapter3.action.Chapter3Action" method="action2">
<result name="action2" type="chain">
<param name="actionName">redirectAction</param>
<param name="namespace">/chapter3</param>
</result>
</action>
</package>
4.redirectAction:外部跳转到Action;
action:
public String action3() {
message = "我是action3中设置的值";
return "action3";
}
struts.xml
<action name="action3" class="chapter3.action.Chapter3Action" method="action3">
<result name="action3" type="redirectAction">redirectAction</result>
</action>
跨命名空间的外部跳转:
public String action4() {
message = "我是action4中设置的值";
return "action4";
}
<action name="action4" class="chapter3.action.Chapter3Action" method="action4">
<result name="action4" type="redirectAction">
<param name="actionName">redirectAction</param>
<param name="namespace">/chapter3</param>
</result>
</action>
分享到:
相关推荐
NULL 博文链接:https://cdxs2.iteye.com/blog/1926350
Struts2 Result类型,整理的非常详细!
struts2中result类型之redirect,重定向
struts2 常用Result类型(type)的用法 Invalid result location value/parameter错误的解决办法
Python 3的简单Result类型,完整类型注释。 这个想法是结果值可以是Ok(value)或Err(error) ,并可以区分两者。 Ok和Err都是封装任意值的类。 Result[T, E]是用于键入的通用类型别名typing.Union[Ok[T], Err[E]] 。...
struts2中result类型之redirectAction
针对struts2对result配置的各种类型详解
结果Result是代表Result类型的go结构。 它可以代表成功或失败。 使用Result,我们可以构建如下的API: latestCommitMessage := openRepository ( url ) . flatMap ( func ( repo interface {}) { return repo . ...
里面包括开发result需要的接口jar包,和接口开发是对数据的判断。
SwiftResult提供的Result类型与提出的Result类型兼容( ),可以将其添加到Swift 5.x的Swift标准库中。用它替换第三方Result类型可以使将代码迁移到Swift 5.x更加容易。 // An overload to return a `Result` ...
Frostware.Result C#中函数结果类型的简单实现目录什么是结果类型,为什么要使用它? 结果类型是try / catch的替代方法,其目的是消除对null的需求并强制处理失败的案例。 通过让您的方法返回Result,它使您可以在...
下面让我们来做一个Velocity模板输出的例子,首先在classes/struts.xml中新建一个Action映射(Mapping),将其result类型设为velocity,如以下代码所示: <result type="velocity">/HelloWorld.vm</result> 例3 ...
使用JSON插件实现JSON类型的Result
struts2 跳转类型 result type chain dispatcher redirect redirect action
一、 Result类型 (type) 19 二、 全局结果集(Globle Result) 20 三、 动态的结果集(dynamic result) 21 四、 带参数的结果集 21 五、 Result总结 22 六、 项目经理: 22 03 OGNL表达式语言 23 04 Struts2-Tags 28 ...
一、 Result类型 (type) 19 二、 全局结果集(Globle Result) 20 三、 动态的结果集(dynamic result) 21 四、 带参数的结果集 21 五、 Result总结 22 六、 项目经理: 22 03 OGNL表达式语言 23 04 Struts2-Tags 28 ...
:OK_hand:如何使用它在返回一个函数时,将其设置为返回Result类型。 Result getSomethingPretty (); 然后添加错误和成功类型。 Result < Exception> getSomethingPretty () {}作为功能的回报,您只需要返回...
type : result类型 不写则选用superpackage的type struts-default.xml中的默认为dispatcher --> <result name="success" type="dispatcher">/talk.jsp</result> <!-- 参数设置 name:对应Action中...
Result类型表示可能是错误的值。 每个Result均为“ Ok并包含成功值,或者为“ Err并包含错误值。 使用Option类型会强制您处理代码中的None值并提高类型安全性。 使用Result类型简化了错误处理,降低了try except...
result类型为整型,返回一个整数,小于零操作没成功 7.关闭不再使用的 如:rs.close(); stmt.close(); con.close(); JDBC编程步骤总结: 1. Load the Driver:Class.forName(); 2. Connect the DateBase: Drive...