想问问,struts1与struts2如何实现这样的功能,方法越多越详细越好。
解决方案 »
- ant 优化问题 发布时间
- 救命啊,就剩下几天了,还遇到这么大的问题。
- 在Linux上不能运行JavaScript,在我自己的机上能夠运行,是不是Linux服务器上Apache少配置了什麽導致???
- JSON数组怎么转换为JAVA可处理对象
- Unable to open location: Document not found on server是什么问题啊
- MYEclipse启动tomcate就出现DEBUG页面
- 关于泛型求组
- struts2.0 为什么自动加入dojo.require("dojo.widget.html.Tooltip")
- 从多方抓取一方时,多发一条sql是怎么回事儿,求指点
- Base64+3DES解密结果部分乱码,请指教!!
- 监听数据库里的数据
- jboss加载问题
如:
<action path="/distributor/delete" type="com.gs.web.esmcol.distributor.DistributorDeleteAction" parameter="method" >
<forward name="list" path="/distributor/list.do?method=formSubmit"/>
</action>
struts2的你只要在<result name="xxx" type="chain">actionname</result>网上这类方法一大堆呢。。随便搜搜就行了,还有源码
2: return new ActionForward("/myaction.do?userid="+userid + "&teamUser="+teamUser + "&doEdit="+doEdit);
3: <result name="success" type="chain" >action 名称 </result> s2: <result name="success" type="chain" >action 名称 </result>
<result name="success" type="redirect-action" >actionName</result>
<struts>
<constant name="struts.objectFactory " value="spring"></constant>
<constant name="struts.i18n.encoding" value="utf-8"></constant>
<package name="" extends="struts-default" >
<action name="login" class="userAction" method="saveUser">
<result name="success">welcome.jsp</result>
<result name="error">error.jsp</result>
</action>
<action name="userlogin" class="userAction" method="loginUser">
<result name="success">welcome.jsp</result>
</action>
</package>
</struts>
(1):chain,<result type="chain">...</result>,顾名思义,这种请求方式是通过拦截器ChainingInterceptor完成的,Action链在ChainingInterceptor执行完源码后,将原Action中的用户请求参数,值栈,session的数据自动赋值为目标Action,简单的说法,也就是在执行多个action过程中,参数都是保留的。
(2)redirect,<result type="redirect">...</result>,这个没什么说的,都懂的。redirect结果类型与Struts2框架默认的结果类型dispatcher相对应。 到dispatcher类型是将请求转发到指定的视图资源,而redirect类型是重定向到指定的视图资源。重定向将会丢失所有的参数、值栈和请求属性,即同时失去了Action的处理结果。而dispatcher是类型转发,将会把上述的所有数据资源转发给视图资源
(3) redirect-action,<result type="redirec-actiont">...</result>,redirect-action结果类型与redirect结果类型非常相似,都是重新生成一个新的请求,都是重新定向。
配置文件里<action name="bbbbbbbbbbbbbbbbb" class="" method="">
<result name="success">/xxxx.jsp</result>
</action><action name="aaaaaaaaaaa" class="" method="">
<result name="success">bbbbbbbbbbbbbbbbb</result>
</action>
<result name="xxx" type="chain"> actionname </result>
关键是chain属性,是一个action转到另外一个action的方法,其次还有
dispatcher:服务器跳转
redirect:客户端重定向
chain:action互转
从com.liuhe.action.IndexAction跳转到com.liuhe.action.OpenAction的openTimeShow
<action name="*" class="com.liuhe.action.IndexAction" method="{1}">
<result name="kfp" type="chain">
<param name="namespace">/open</param>
<param name="actionName">openTimeShow</param>
</result>
<result name="*">/${result}.jsp</result>
</action>