strutsとspring関連配置


1)Mave 2は、プロジェクト全体の構築過程を管理するツールであり、コンパイル、テストの実行、レポートの作成、および構築を管理する製品であり、開発者にとって最も魅力的なものの一つは、構築製品を管理することである.
 
 
 
 
 
 
 
2)web.xml
 
<filter>   Struts 2    org.apache.struts.dispatcher.Filter Dispactch
 
<filter-mapping>    Struts 2   
 
2、スプリング配置;
Springプロファイルを読み込む
    contextConfig Location  classipath*:spring/appication Controtext.xml 
 
  「web.xml」のプロファイルには、二つのコードを追加する必要があります.第一部は、アプリケーションオブジェクトとSpringの統合をアクティブにするためのlistenerを登録するためのものである.
 
 
    org.springframe ewek.web.com ntxt.Context Loader Listener 
 
 
 
3)struts.xml
 
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "struts-2.1.dtd" >
<struts>
	<!--
		1、“struts-default.xml” “struts-plugin.xml”       
		name :package    ,     ;
		namespace:      http://xx.com/order/index.do
		extends :      
	-->;

	<package name="order" namespace="/order" extends="struts-default,json-default">
		<!--     ,    fillter  -->
		<interceptors>
			<interceptor name="orderActionInterceptor" class="com.feifei.bin.od.utils.OrderActionInterceptor"></interceptor>
			<interceptor name="sessionInterceptor" class="com.bin.bin.od.utils.SessionInterceptor"/>
			
			<!--    ,     -->
			<interceptor-stack name="orderInterceptorStack">
				<interceptor-ref name="defaultStack">
					<param name="exception.logEnabled">true</param>   
				        <param name="exception.logLevel">error</param>   
				</interceptor-ref>
				<interceptor-ref name="orderActionInterceptor"></interceptor-ref>
			</interceptor-stack>
			
			<interceptor-stack name="sessionInterceptorStack">
				<interceptor-ref name="orderInterceptorStack"></interceptor-ref>
				<interceptor-ref name="sessionInterceptor"></interceptor-ref>
			</interceptor-stack>

		</interceptors>

		<!--        -->
		<global-results>
			<result name="index">/index.jsp</result>
			<result name="unError" type="redirect">/common/500.html</result>
			<result name="indexx" type="redirect">/common/indexx.html</result>
		</global-results>	
		
		<!--
			http://xx.com/order/shoppingCart_success.do
			mothod -> shoppingCartAction     success   
			shoppingCart_success.jsp   
		-->
		<action name="shoppingCart_*" method="{1}" class="shoppingCartAction">
			<result name="shoppingCart_showAddToCartPage">/page/order/shoppingCart_addToCart.jsp</result>
			<result name="shoppingCart_{1}">/page/order/shoppingCart_{1}.jsp</result> 
			<result name="shoppingCart_bcustomers">/page/order/shoppingCart_customer.jsp</result>
			<interceptor-ref name="orderInterceptorStack"></interceptor-ref>
		</action>
		
		<!-- 
			1、     struts2       
			2、    ,       
		-->
	        <include file="struts/struts-order.xml"></include>

	</package>
</struts>
 
 
 
2、注意が必要です.
 
 
 <!--      ,     URL action    
 <constant name="struts.enable.SlashesInActionNames" value="true" /> 
	 action    '/'      true
	 ${viewpath} controller       
-->
<action name="*/*!*" class="net.jacker.ww.{1}.{2}Action" method="{3}"> 
	<result name="default" type="dispatcher">/{1}/{2}.jsp</result>
	<result name="view" type="dispatcher">${viewpath}.jsp</result>
	 <result name="redirect" type="redirect">${viewpath}</result>
</action>
<action name="*/*" class="net.jacker.ww.{1}.{2}Action">
	<result name="default" type="dispatcher">/{1}/{2}.jsp</result>
	<result name="view" type="dispatcher">${viewpath}.jsp</result>
	<result name="redirect" type="redirect">${viewpath}</result>
</action>
 
 http://xx.com/order/shoppingCart_success.do mothod->shopingCartAction類にはsuccess方法shopingCartがあります.success.jspページ