本文大部分copy api。仅作平时查找,质量不高。
内置Result实现类:
chain
Action链式处理的结果类型
1)This result invokes an entire other action, complete with it's own interceptor stack and result.
2)代码中有一句actionProxy.execute()连接下一个[action流程](包括拦截器,action,preResultListeners,result)。下一次[action流程]使用上一次[action流程]的ActionContext(这么多action属于一次http请求,且是同一个线程)。
3)HistoryAction用于防止循环调用action。skipActions用于标记哪些[action流程]不用检查是否已经运行过。
4)可用来forward action,下面的dispatch类型不能forward action,redirect[action]类型是redirect action。重新创建一个ActionProxy再跑一次xwork。
【参数】
actionName
|
默认,接着要串联的action
|
namespace
|
used to determine which namespace the Action is in that we're chaining. If namespace is null, this defaults to the current namespace
|
Method
|
used to specify another method on target action to be invoked. If null, this defaults to execute method
|
skipActions
|
可选,the list of comma separated action names for the actions that could be chained to
|
【例子 】
<package name="public" extends="webwork-default">
<!-- Chain creatAccount to login, using the default parameter -->
<action name="createAccount" class="...">
<result type="chain">login</result>
</action>
<action name="login" class="...">
<!-- Chain to another namespace -->
<result type="chain">
<param name="actionName">dashboard</param>
<param name="namespace">/secure</param>
</result>
</action>
</package>
<package name="secure" extends="webwork-default" namespace="/secure">
<action name="dashboard" class="...">
<result>dashboard.jsp</result>
</action>
</package>
dispatcher
Includes or forwards to a view (usually a jsp).使用RequestDispatch的forward或include方法转发到another resource (servlet, JSP file, or HTML file) on the server
【参数】
location :默认 the location to go to after execution (ex. jsp).
parse :true by default. If set to false, the location param will not be parsed for Ognl expressions. 该参数指定是否允许杂实际视图名字中使用OGNL表达式,该参数默认为true。如果设置该参数为false,则不允许在实际视图名中使用表达式。通常无须修改该属性。
stream
A custom Result type for send raw data (via an InputStream) directly to the HttpServletResponse. Very useful for allowing users to download content. 。这些参数也可在valuestack上定义
【参数】
contentType:the stream mime-type as sent to the web browser (default = text/plain).
contentLength:the stream length in bytes (the browser displays a progress bar).
contentDispostion: the content disposition header value for specifing the file name (default = inline, values are typically filename="document.pdf".
inputName:the name of the InputStream property from the chained action (default = inputStream). ,或在the invocation variable stack上
bufferSize - the size of the buffer to copy from input to output (default = 1024).
使用stream类型返回比使用[在action中返回void并使用response控制输出]在某些情况下有用,比如在客户端显示返回内容之前要作检查,类似PreResultListener的功能。
【例】
<action name="getNations" class="action.PlayAmountAction" method="getNations">
<result name="success" type="stream"></result>
</action>
protected void configureStreamResult(String content)
{
/**
* protected String contentType = "text/plain";
* protected String contentLength;
* protected String contentDisposition = "inline";
* protected String contentCharSet ;
* protected String inputName = "inputStream";
* protected InputStream inputStream;
* protected int bufferSize = 1024;
* protected boolean allowCaching = true;
*/
ValueStack vs=ActionContext.getContext().getValueStack();
ByteArrayInputStream bais=null;
try {
bais = new ByteArrayInputStream(content.getBytes("UTF-8"));
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
vs.set("inputStream", bais);
vs.set("contentCharSet", "UTF-8");
vs.set("contentType", "application/json");
vs.set("contentLength",bais.available());
vs.set("bufferSize", bais.available());
vs.set("allowCaching", false);
}
freemarker
使用Freemarker模板引擎渲染视图。Ftl数据如何绑定在ActionContext那一篇文中。
FreemarkerManager类用于配置模板加载路径:可以是以下2个
1)relative to the web root folder. eg /WEB-INF/views/home.ftl
2)A classpath resuorce. eg com/company/web/views/home.ftl
【参数】
This result type takes the following parameters:
location :默认 the location of the template to process.
Parse:true by default. If set to false, the location param will not be parsed for Ognl expressions.
contentType:defaults to "text/html" unless specified.
httpheader
用于控制特殊的HTTP行为。A custom Result type for setting HTTP headers and status by optionally evaluating against the ValueStack.
【参数】
status :the http servlet response status code that should be set on a response.
parse :true by default. If set to false, the headers param will not be parsed for Ognl expressions.
headers :header values.
【例子】 :
<result name="success" type="httpheader">
<param name="status">204</param>
<param name="headers.a">a custom header value</param>
<param name="headers.b">another custom header value</param>
</result>
redirect
Calls the sendRedirect method to the location specified. The response is told to redirect the browser to the specified location (a new request from the client). The consequence of doing this means that the action (action instance, action errors, field errors, etc) that was just executed is lost and no longer available. This is because actions are built on a single-thread model. The only way to pass data is through the session or with web parameters (url?name=value) which can be OGNL expressions.
【参数】
location :默认 the location to go to after execution.
Parse:true by default. If set to false, the location param will not be parsed for Ognl expressions.
redirectAction
This result uses the ActionMapper provided by the ActionMapperFactory to redirect the browser to a URL that invokes the specified action and (optional) namespace. This is better than the ServletRedirectResult because it does not require you to encode the URL patterns processed by the ActionMapper in to your struts.xml configuration files. This means you can change your URL patterns at any point and your application will still work. It is strongly recommended that if you are redirecting to another action, you use this result rather than the standard redirect result.
velocity
处理velocity模板
xslt
处理xslt模板
plainText
不处理,直接显示文件
PreResultListener
PreResultLIstener是一个监听接口,可以在Action完成控制处理后,系统转入实际的物理视图之间被回调
Struts2应用可由Action、拦截器添加PreResultListener监听器,添加PreResultListener监听器通过ActionInvocation的addPreResultListener()方法完成
1)Action添加了PreResultListener监听器,该监听器就可以在应用转入实际物理视图之前回调该监听器的beforeResult()方法;
2)拦截器添加了PreResultListener监听器,该监听器会对该拦截器设置可以拦截的所有Action起作用。
beforeResult
(ActionInvocation invocation, String resultCode)
resultCode是指<result name=””>中name的值,即视图的逻辑名。
Interceptor(s)àactionàpreResultListeneràresultàinterceptor(s)
如果action中的方法返回void,这里的resultCode 就是null
分享到:
相关推荐
这是ROC曲线绘制和AUC值计算的数据文件。大家在用Python绘制ROC曲线是可下载使用这个文件。相关代码也能够在我的博客里找到。 https://blog.csdn.net/weixin_44830815
于是就研究使用Struts2的XSLT result方式来做页面显示。 网上相关的内容非常的少,我也研究了好久才玩转的。一开始总是有一些莫名其妙的问题出现,但最后基本上都是和配置相关的比较多。现在这个例子是整个工程项目...
倒排记录结果展示,通过用代码实现倒排索引,就可以得到相关的结构,然后把结果导出到这个文件中,方便我们查看,也就是,可以再对,这个文件进行检索
mitama-cpp-result提供result<T> , maybe以及相关的单子函数(如“编程语言Rust”中的和 )。 测试状态 参考 。 如果您需要有关仅夜间API的信息,请在develop分支中构建最新文档。 建立最新文件(需要) mitama-...
结果Result是一个 Swift 框架,包括Result枚举和一个ErrorType协议。 这两种类型都非常小。 我期待 Swift 未来的两个变化: 修复了 Swift 编译器问题,该问题需要Result的Success... 有关详细信息,请参阅许可证文件。
matlab有关数字信道化系统的数字AGC研究-AGC_CONTROL_30000_result.rar AGC,它的作用是当信号源较强时,使其增益自动降低;当信号较弱时,又使其增益自动增高,从而保证了强弱信号的均匀性,对输入的信号进行一个稳定...
MyResultUI 构建设置 # install dependencies $ npm install # serve with hot reload at localhost:3000 $ npm run dev # build for production and launch server ... 有关工作原理的详细说明,请查看 。
自然语言处理相关的分词数据
自然语言处理相关的分词数据
它为与进度相关的重要通信提供了自动化,并集中了一切。 结果是可以看到您和您的队友的重点,您和您的队友的关系以及需要注意的地方。 通过提醒每个人您需要的结果并保持较低的摩擦,ResultMaps可以激发并实现更好的...
相位法的图像拼接,利用傅里叶变换的原理,将两幅图像进行拼接
数字普惠金融的发展可能会对城市创新产生重大的影响,对二者关系的相关研究发表在《经济学家》等重要的CSSCI核心期刊上。
2: Result := '该驱动器是可移动驱动器'; 3: Result := '该驱动器是固定驱动器'; 4: Result := '该驱动器是网络驱动器'; 5: Result := '该驱动器是CD-ROM驱动器'; 6: Result := '该驱动器是虚拟驱动器...
sarkari Result提供有关印度各地的录取卡,考试,工作,警报等以及工作的信息 sarkari结果提供有关印度各地Sarkari结果,考试,免费工作提示,录取卡和工作的信息。 单击下面给出的“网站”链接,获取工作,结果,...
result字符串,如果status为“ ok”,则该字符串应等于“ ok”,或者应包含有关结果为何不正常的详细信息。 data可以是任何值,并且可以包含结果数据。安装npm i tm-result 职能genOk生成“确定”结果对象。 genNOk...
Rojgar Result是一个Job网站,提供该网站上所有可用的Category职位 Rojgar Results提供有关印度各地Sarkari结果,考试,免费工作提醒,录取卡和工作的信息。 单击下面给出的“网站”链接,获取工作,结果,考试...等
苹果脚本结果 将AppleScript结果转换为其等效JavaScript表示形式 安装 $ npm install apple...有关的 :运行AppleScript并以本机JavaScript数据类型获取结果 :运行AppleScript并以字符串形式获取结果 node-osasc
NPOI可以在没装OFFICE的情况下操作EXCEL,WORD等,也不用在程序中引用微软的office组件。... 代码如下: using NPOI; //…… public FileResult GetFile(...以后会添加更多的有关MVC的方法,关注哦。
yolov8肢体模型与测试代码 from ultralytics import YOLO import cv2 # 加载模型 model = YOLO('yolov8x-pose.pt') bady_path = "body.avi" ...# result_keypoint = results.keypoints.xyn.cpu().numpy()[0]