struts+spring+hibernate的web应用【7】

第十九部分:接着编写配置文件。 struts-config 包中新建 struts-config.xml 。代码如下:

 

<? xml version="1.0" encoding="ISO-8859-1" ?> 
 <! DOCTYPE struts-config PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"
    "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd" > 
 
 < struts-config > 
     < form-beans > 
         < form-bean  name ="productsForm"  type ="com.game.products.web.forms.ProductsForm"   /> 
     </ form-beans > 
    
     < global-forwards > 
         < forward  name ="success"  path ="/products/product_success.jsp"   /> 
         < forward  name ="failure"  path ="/products/product_failure.jsp"   /> 
     </ global-forwards > 
    
     < action-mappings > 
         < action  path ="/getProducts"  type ="org.springframework.web.struts.DelegatingActionProxy"  parameter ="method"  scope ="request"  validate ="false" > 
             < forward  name ="all"  path ="/products/products.jsp"   /> 
         </ action > 
         < action  path ="/getProduct"  type ="org.springframework.web.struts.DelegatingActionProxy"  parameter ="method"  scope ="request"  validate ="false" > 
             < forward  name ="one"  path ="/products/product.jsp"   /> 
         </ action > 
         < action  path ="/deleteProduct"  type ="org.springframework.web.struts.DelegatingActionProxy"  parameter ="method"  scope ="request"  validate ="false" >             
         </ action > 
         < action  path ="/addProductPage"  type ="org.springframework.web.struts.DelegatingActionProxy"  parameter ="method"  scope ="request"  validate ="false" > 
             < forward  name ="add"  path ="/products/addproduct.jsp"   /> 
         </ action > 
         < action  path ="/addProduct"  name ="productsForm"  type ="org.springframework.web.struts.DelegatingActionProxy"  parameter ="method"  scope ="request"  validate ="false"  input ="/product_failure.jsp" > 
         </ action > 
         < action  path ="/updateProduct"  name ="productsForm"  type ="org.springframework.web.struts.DelegatingActionProxy"  parameter ="method"  scope ="request"  validate ="false"  input ="/product_failure.jsp" > 
         </ action > 
        
         < action  path ="/returnProduct"  type ="org.springframework.web.struts.DelegatingActionProxy"  parameter ="method"  scope ="request"  validate ="false" > 
             < forward  name ="all"  path ="/products/products.jsp"   /> 
         </ action > 
         < action  path ="/queryProducts"  type ="org.springframework.web.struts.DelegatingActionProxy"  parameter ="method"  scope ="request"  validate ="false" > 
             < forward  name ="all"  path ="/products/products.jsp"   /> 
         </ action > 
     </ action-mappings > 
    
     < message-resources  parameter ="com.game.resources.ApplicationResourcesProducts"   /> 
    
     < plug-in  className ="org.apache.struts.validator.ValidatorPlugIn" > 
         < set-property  property ="pathnames" 
            value ="/WEB-INF/struts-validator/validator-rules.xml,/WEB-INF/struts-validator/validation.xml" /> 
     </ plug-in >     
    
 </ struts-config > 

 

第二十部分:需要注意的是,这里的 action 交由 spring DelegatingActionProxy 管理了。 

                  打开 applicationContext.xml ,接着添加如下代码:

 

<!--  View  --> 
     < bean  name ="/getProducts"  class ="com.game.products.web.actions.ProductsAction"  singleton ="false" > 
         < property  name ="productsService" > 
             < ref  bean ="productsService" /> 
         </ property > 
         < property  name ="pagerService" > 
             < ref  bean ="pagerService" /> 
         </ property > 
     </ bean > 
     < bean  name ="/getProduct"  class ="com.game.products.web.actions.ProductsAction"  singleton ="false" > 
         < property  name ="productsService" > 
             < ref  bean ="productsService" /> 
         </ property > 
     </ bean > 
     < bean  name ="/deleteProduct"  class ="com.game.products.web.actions.ProductsAction"  singleton ="false" > 
         < property  name ="productsService" > 
             < ref  bean ="productsService" /> 
         </ property > 
     </ bean > 
     < bean  name ="/addProductPage"  class ="com.game.products.web.actions.ProductsAction"  singleton ="false" > 
         < property  name ="productsService" > 
             < ref  bean ="productsService" /> 
         </ property > 
     </ bean > 
     < bean  name ="/addProduct"  class ="com.game.products.web.actions.ProductsAction"  singleton ="false" > 
         < property  name ="productsService" > 
             < ref  bean ="productsService" /> 
         </ property > 
     </ bean > 
     < bean  name ="/updateProduct"  class ="com.game.products.web.actions.ProductsAction"  singleton ="false" > 
         < property  name ="productsService" > 
             < ref  bean ="productsService" /> 
         </ property > 
     </ bean > 
     < bean  name ="/returnProduct"  class ="com.game.products.web.actions.ProductsAction"  singleton ="false" > 
         < property  name ="productsService" > 
             < ref  bean ="productsService" /> 
         </ property > 
         < property  name ="pagerService" > 
             < ref  bean ="pagerService" /> 
         </ property > 
     </ bean > 
     < bean  name ="/queryProducts"  class ="com.game.products.web.actions.ProductsAction"  singleton ="false" > 
         < property  name ="productsService" > 
             < ref  bean ="productsService" /> 
         </ property > 
         < property  name ="pagerService" > 
             < ref  bean ="pagerService" /> 
         </ property > 
     </ bean > 

 

 

你可能感兴趣的:(spring,bean,Web,Hibernate,struts)