欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

struts2 action跳转调用另一个程序

程序员文章站 2023-11-20 21:36:34
目的:主要为了在一个action成功后跳转调用另一个程序。 struts2.xml [html] 复制代码 代码如下:
目的:主要为了在一个action成功后跳转调用另一个程序。
struts2.xml
[html]
复制代码 代码如下:

<?xml version="1.0" encoding="utf-8"?>
<!doctype struts public "-//apache software foundation//dtd struts configuration 2.0//en"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts> <!-- 指定为开发模式(默认值为false) -->
<constant name="struts.devmode" value="false" />
<constant name="struts.i18n.encoding" value="utf-8"/>
<constant name="struts.custom.i18n.resources" value="message"></constant>
<!-- 上传文件临时文件位置 -->
<constant name="struts.multipart.savedir" value="c:\"></constant>
<!--
<include file="com/lanstar/config/struts/struts_user.xml"/>
--> www.jb51.net
<package name="resume" namespace="/" extends="struts-default">
<action name="analysisaction" class="analysisaction">
<result name = "success">/jsp/uploadresult.jsp</result>
</action>
<action name="upload" class = "uploadaction">
<result name="success" type= "chain">
<param name="actionname">analysisaction</param>
</result>
<!--<result name = "success">/jsp/uploadresult.jsp</result>
--><result name = "input">/jsp/upload.jsp</result>
<result name="error">/jsp/error/error.jsp</result>
<interceptor-ref name="fileupload">
<!-- 单个上传文件的最大值-->
<param name="maximumsize">409600</param>
<!-- 只能上传的文件的类型,可到tomcat的web-xml中查看各种文件类型-->
<param name="allowedtypes">text/html,application/msword</param>
</interceptor-ref>
<interceptor-ref name="defaultstack"></interceptor-ref>
</action>
</package>
</struts>

spring.xml
[html]
复制代码 代码如下:

<!--
- application context definition for jpetstore's business layer.
- contains bean references to the transaction manager and to the daos in
- dataaccesscontext-local/jta.xml (see web.xml's "contextconfiglocation").
-->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemalocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<!-- service start -->
<bean id="uploadaction" class="com.lanstar.resume.action.uploadaction" scope="prototype">
</bean>
<bean id="analysisaction" class="com.lanstar.resume.action.analysisaction" scope="prototype">
</bean>
</beans>

两种方式:
需要保存前一个action的属性信息时使用:
[java]
复制代码 代码如下:

<result name="success" type= "chain"><param name="actionname">analysisaction</param></result>

不保存前一个action的参数可以用这种方法:
[java]
复制代码 代码如下:

<result name="success" type= "redirect-action"><param name="actionname">analysisaction</param></result>