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>
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>
推荐阅读
-
struts2 action跳转调用另一个程序
-
Struts2——action间的跳转
-
Struts2 Action中跳转Action
-
WebSphere升级到6.1.0.17所有struts2的程序中的Action都不能找到
-
WebSphere升级到6.1.0.17所有struts2的程序中的Action都不能找到
-
struts2 跳转类型 result type=chain、dispatcher、redirect(redirect-action)(转载)
-
struts2中Action跳转的convention 配置
-
当前小程序 跳转 另一个小程序支付(跳转到当前小程序的某个页面)
-
Struts2——action间的跳转
-
Struts2 Action中跳转Action