strruts result 怎么传递通达信参数 str2con

strruts2+freemarker问题_百度知道
strruts2+freemarker问题
我在action里面配置ctx.getValueStack().set(&ifvar&, 1);在模板里面这样写&#assign sifvar&
&br& ${ifvar?int}
&/#assign&
&#if sifvar==1&
ifvar的值为 ${ifvar}
&/#if&报错:FreeMarker template error!The only legal comparisons are between two numbers, two strings, or two dates.Left
hand operand is a freemarker.template.SimpleScalarRight hand operand is a freemarker.template.SimpleNumberThe problematic instruction:----------==& if sifvar==1 [on line 24, column 5 in userLogin/alltest.ftl]----------Java backtrace for programmers:----------freemarker.template.TemplateException: The only legal comparisons are between two numbers, two strings, or two dates.Left
hand operand is a freemarker.template.SimpleScalarRight hand operand is a freemarker.template.SimpleNumber另如果action中设置ifvar=“1” 然后在页面将ifvar转化为string类型
&#if sifvar==1& 老是false
&#if sifvar=1&也是false
&#if sifvar!=1&确是true 忘高手给与解答 更希望q我
提问者采纳
&#assign sifvar=ifvar?int& &#if sifvar?int=1& ifvar的值为 ${ifvar} &/#if&另外,struts2里面用free畅触扳吠殖杜帮森爆缉marker的话,不需要那么写的,只要不是private变量,都能直接引用的。
提问者评价
谢谢 ,struts2会自动将属性封装倒request里面这个知道谢谢了
其他类似问题
为您推荐:
freemarker的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁struts2 - Struts interceptor giving a stream result - Stack Overflow
to customize your list.
Announcing Stack Overflow Documentation
We started with Q&A. Technical documentation is next, and we need your help.
Whether you're a beginner or an experienced developer, you can contribute.
I got an interceptor that I'm trying to get to output a stream when a certain action is calling. This is part of my code in the inteceptor:
InputStream inputS
public String intercept(ActionInvocation invocation) throws Exception
if (currAction.contentEquals("actionToTest"))
String result = "TRUE";
inputStream = new ByteArrayInputStream(result.getBytes("UTF-8"));
return "resultToGiveStream";
inputStream has got it's own getters and setters.
And in struts.xml:
&global-results&
&result type="stream" name="resultToGiveStream"&
&param name="contentType"&text/plain&/param&
&param name="inputName"&inputStream&/param&
&/global-results&
But when I call actionToTest I only receive this in my console:
2011-maj-18 11:19:16 com.opensymphony.xwork2.monsLogger error
ALLVARLIG: Can not find a java.io.InputStream with the name [inputStream] in the invocation stack. Check the &param name="inputName"& tag specified for this action.
Is it a lost cause to get it to output what I want? I haven' found anyone doing anything similar.
This code is an atempt for a workaround for .
1,05411213
Struts2 is looking for the getInputStream() method on your action and it isn't finding it.
You could try placing the inputStream on the stack manually from within the interceptor. Something like:
invocation.getInvocationContext().put("inputStream", inputStream);
8,58622043
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you're looking for?
Browse other questions tagged
Stack Overflow works best with JavaScript enabled4194人阅读
J2EE(10)
& 开始一直配置为:
&action name="org" class="com.spl.action.OrganizationAction"&
&result name="index"&/org/index.jsp&/result&
&result name="add_input"&/org/add_Input.jsp&/result&
&result name="add_success" type="redirectAction"&org!list?orgDto.pid=${orgDto.pid}&/result&
&result name="errorMessage"&/message.jsp&/result&
&一直用抓包工具抓包,发现redirectAction的Url为:org!list,郁闷至极,后来改为:
&action name="org" class="com.spl.action.OrganizationAction"&
&result name="index"&/org/index.jsp&/result&
&result name="add_input"&/org/add_Input.jsp&/result&
&result name="add_success" type="redirectAction"&
&param name="actionName"&org!list&/param&
&param name="orgDto.pid"&${orgDto.pid}&/param&
&result name="errorMessage"&/message.jsp&/result&
& 一切正常...注意:orgDto.pid为action中的Object属性
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:173532次
积分:2070
积分:2070
排名:第13280名
原创:56篇
转载:10篇
评论:28条
(10)(1)(3)(6)(2)(1)(2)(1)(2)(13)(4)(3)(6)(12)QYin 的BLOG
用户名:QYin
文章数:270
评论数:76
访问量:520062
注册日期:
阅读量:5863
阅读量:12276
阅读量:318055
阅读量:1030184
[匿名]51cto游客:
[匿名]sdfsdf:
51CTO推荐博文
在struts.xml配置文件中遇到了param,有点迷糊,上网查了查&&似乎明白些了
&action name=&Log*& method=&loginFrame{1}& class=&member.loginIndeAct&&
&&&&result&${tplPath}&/result&
&&&&result name=&logout& type=&redirectAction&&
&&&&&param name=&namespace&&/jeecms&/param&
&&&&&param name=&actionName&&LoginFrameInput&/param&
&&&&/result&
&&&/action&
这里的action
是Log,他包含了登陆和退出,当系统在登录的时候就直接返回${tplPath}就可以了;在退出的时候需要返回到登陆页面,所以退出的时候是转发到 action的,转发到action肯定要告诉系统转发到那个action,该action的namespace是什么,名字是什么,就是通过param 该属性老告知struts2的;当然param还有其他用法,不过一般就用这个就差不多了,综上得出:
param标签主要用于为其他标签提供参数,例如bean和include标签。
param参数设置:
name:可选属性,指定设置参数名称
value:可选属性,指定参数的值
id:可选属性,指定该元素引用id
看到这,野猪似乎感觉清楚了许多,嘿嘿&&
下面还搜到了一些信息,等野猪不是很清楚的时候再看看吧&&
chain&&& &&
&&& 用来处理Action链,被跳转的action中仍能获取上个页面的值,如request信息。&&&&&&
&&& com.opensymphony.xwork2.ActionChainResult&&& &&
dispatcher&&& &&
&&& 用来转向页面,通常处理JSP&&& &&
&&& org.apache.struts2.dispatcher.ServletDispatcherResult&&&&&&
freemaker&&& &&
&&& 处理FreeMarker模板&&& &&
&&& org.apache.struts2.views.freemarker.FreemarkerResult&&& &&
httpheader&&&&&&
&&& 控制特殊HTTP行为的结果类型&&& &&
&&& org.apache.struts2.dispatcher.HttpHeaderResult&&&
stream&&& &&
&&& 向浏览器发送InputSream对象,通常用来处理文件下载,还可用于返回AJAX数据&&& &&
&&& org.apache.struts2.dispatcher.StreamResult&&& &&
velocity&&& &&
&&& 处理Velocity模板&&& &&
&&& org.apache.struts2.dispatcher.VelocityResult&&& &&
xslt&&& &&
&&& 处理XML/XLST模板&&& &&
&&& org.apache.struts2.views.xslt.XSLTResult&&& &&
plainText&&& &&
&&& 显示原始文件内容,例如文件源代码&&& &&
&&& org.apache.struts2.dispatcher.PlainTextResult&&& &&
plaintext&&& &&
&&& 显示原始文件内容,例如文件源代码&&& &&
&&& org.apache.struts2.dispatcher.PlainTextResult&
redirect& &&
&&& 重定向到一个URL&,被跳转的页面中丢失传递的信息,如request&& &&
&&& org.apache.struts2.dispatcher.ServletRedirectResult&&&&&&
redirectAction&&& &&
&&& 重定向到一个Action&,跳转的页面中丢失传递的信息,如request&&&&&&&&
&&& org.apache.struts2.dispatcher.ServletActionRedirectResult&&& &&
redirect-action&&& &&
&&& 重定向到一个Action&,跳转的页面中丢失传递的信息,如request&&&&&&&&
&&& org.apache.struts2.dispatcher.ServletActionRedirectResult&&&
注:redirect与redirect-action区别
一、使用redirect需要后缀名 使用redirect-action不需要后缀名
二、type=&redirect& 的值可以转到其它命名空间下的action,而redirect-action只能转到同一命名空下的 action,因此它可以省略.action的后缀直接写action的名称。
&result name=&success& type=&redirect&&viewTask.action&/result&
&result name=&success& type=&redirect-action&&viewTask&/result&
附:redirect-action 传递参数
&name=&enterpreinfo&&class=&preinfoBusinessAction&&&&&method=&enterPreinfoSub&&&
&&&name=&success&&type=&redirect-action&&&
&&&&&showpreinfo?preinfo.order_number=${preinfo.order_number}&pany_name=${pany_name} &&
&&name=&error&&type=&redirect&&&
&&&&&name=&location&/error.jsp&&
& &因为使用了redirect-action,所以要注意不能将
showpreinf?preinfo.order_number=${preinfo.order_number}写成
showpreinf.action?preinfo.order_number=${preinfo.order_number}
其中${}为EL表达式,获取action:enterpreinfo中属性的值;在这个配置文件里,多个参数的连接符使用了&&&,但XML的语法规范,应该使用&&&代替&&&,原理和HTML中的转义相同,开始没有注意,在struts分析配置文件时,总是报出这样的错误:
json&& 一般很容易忽略的一个地方(在EXT中非常有用)
&package&name=&struts2&&extends=&json-default&&namespace=&/&&&&&&&&&&&&&action&name=&login&&class=&loginAction&&method=&login&&&&&&&&&&&&&&&&&result&type=&json&&&&&&&&&&&&&&&&&&&&&param&name=&includeProperties&&success,result&/param&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&/result&&&&&&&&&&&&&&&&&&&&&&&&&/action&&&&&&&&&&&&action&name=&main&&class=&loginAction&&method=&main&&&&&&&&&&&&&&&&&result&name=&main&&/index.jsp&/result&&&&&&&&&&&&&&&&&&&&&/action&&&&&&&&&/package&&&&package name=&struts2& extends=&json-default& namespace=&/&&
&action name=&login& class=&loginAction& method=&login&&
&result type=&json&&
&param name=&includeProperties&&success,result&/param&
&action name=&main& class=&loginAction& method=&main&&
&result name=&main&&/index.jsp&/result&
&/package&
private&boolean&success&&=&true;&&private&String&result&=&&main.action&;&&&&private boolean success
= private String result = &main.action&; //getter和setter方法略
以上的success和result互相对应到了
&name=&includeProperties&success,result&&&&&param name=&includeProperties&&success,result&/param&
struts2会根据其设置的值匹配跳转
对于json一般情况下很少用到,但是在处理ext的时候会用到这个属性类型,这个地方也是经常被忽略的。
最后感觉还是应该查一下文档给野猪看看,嘿嘿:
Redirect Action Result
actionName (default) - the name of the action that will be redirect to
namespace - used to determine which namespace the action is in that we're redirecting to . If namespace is null, this defaults to the current namespace
extends=&struts-default&&
class=&...&&
&dashboard
extends=&struts-default& namespace=&/secure&&
class=&...&&
dashboard.jsp
type=&redirect-action&&error
class=&...&&
extends=&struts-default& namespace=&/passingRequestParameters&&
The redirect-action url generated will be :
/genReport/generateReport.action?reportType=pie&width=100&height=100
class=&...&&
type=&redirect-action&&
&generateReport
&/genReport
Redirect Result
location (default) - 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.
type=&redirect&&
&package name=&passingRequestParameters& extends=&struts-default& namespace=&/passingRequestParameters&&
&-- Pass parameters (reportType, width and height) --&
The redirect-action url generated will be :
/genReport/generateReport.jsp?reportType=pie&width=100&height=100
&action name=&gatherReportInfo& class=&...&&
&result name=&showReportResult& type=&redirect&&
&param name=&location&&generateReport.jsp&/param&
&param name=&namespace&&/genReport&/param&
&param name=&reportType&&pie&/param&
&param name=&width&&100&/param&
&param name=&height&&100&/param&
&/package&
这下感觉怎么样了?野猪!多看看文档!
最后,又看了一眼result的默认参数:
type=&dispatcher&&
&/ThankYou.jsp
呵呵&&这还比较满意!吃饭去!野猪!
了这篇文章
类别:┆阅读(0)┆评论(0)
21:35:34 12:13:27 15:25:18}

我要回帖

更多关于 result 传递参数 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信