struts和spring的配置实例

1.web.xml

<?xml version="1.0" encoding="UTF-8"?>
http://java.sun.com/xml/ns/j2ee"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4"
 xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee   http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
 
  action
  
   org.apache.struts.action.ActionServlet
  
  
   config
   /WEB-INF/struts-config.xml
  
  
   debug
   3
  
  
   detail
   3
  
  0
 
 
  action
  *.do
 
 
  
  action_tmp
  
   org.apache.struts.action.ActionServlet
  
  
   config
   /WEB-INF/struts-config.xml
  
  
   debug
   3
  
  
   detail
   3
  
  0
 
<!-- 对会员进行过滤 --&gt 

 <!--
  
   This is the description of my J2EE component
  
  
   This is the display name of my J2EE component
  
  UsernameValidate
  
   com.hb.shop.servlet.UsernameValidate
  
 

 --&gt
 <!--
  UsernameValidate
  /UsernameValidate
 
 


 --&gt
<!-- 
  Kaptcha
  
   com.google.code.kaptcha.servlet.KaptchaServlet
  
 
 
  Kaptcha
  /kaptcha.jpg
 
--&gt
<!-- 对会员进行登陆过滤(ypf) --&gt

 
<!--  
  userLoginFilter
  
   com.hb.shop.help.userLoginFilter
  
 
 
  userLoginFilter
  /index.jsp
 
 --&gt
<!-- 对会员进行登陆过滤(ypf) --&gt 

 
  
  testAction
  
   com.hb.shop.web.form.SetEncodingActionServlet
  
  
   config
   /WEB-INF/struts-config.xml
  
  
   encoding
   utf-8
  
  2
 
 
  testAction
  *.do
 

 

 
  ViewCheckFilter
  
   com.hb.shop.web.action.ViewCheckFilter
  
 

 
  ViewCheckFilter
  /jsp/admin/addGoods.jsp
 
 
  ViewCheckFilter
  /jsp/admin/addType.jsp
 
 
  ViewCheckFilter
  /jsp/admin/adminBody.jsp
 
 
  ViewCheckFilter
  /jsp/admin/adminIndex.jsp
 
 
  ViewCheckFilter
  /jsp/admin/adminLeft.jsp
 
 
  ViewCheckFilter
  /jsp/admin/adminLow.jsp
 
 
  ViewCheckFilter
  /jsp/admin/adminMain.jsp
 
 
  ViewCheckFilter
  /jsp/admin/adminTop.jsp
 
 
  ViewCheckFilter
  /jsp/admin/completeOrders.jsp
 
 
  ViewCheckFilter
  /jsp/admin/editGoods.jsp
 
 
  ViewCheckFilter
  /jsp/admin/editOrder.jsp
 
 
  ViewCheckFilter
  /jsp/admin/editOrderList.jsp
 
 
  ViewCheckFilter
  /jsp/admin/editType.jsp
 
 
  ViewCheckFilter
  /jsp/admin/listAllGoods.jsp
 
 
  ViewCheckFilter
  /jsp/admin/listAllTypes.jsp
 
 
  ViewCheckFilter
  /jsp/admin/orderInfo.jsp
 
 
 
 
 
 
 
 
 
 
 
  userLoginFilter
  
   com.hb.shop.tool.userLoginFilter
  
 

 
  userLoginFilter
  /balance.jsp
 
 
  userLoginFilter
  /buy2.jsp
 
 
  userLoginFilter
  /check.jsp
 
 
 
  userLoginFilter
  /member/*
 

2.struts-config.xml

<?xml version="1.0" encoding="UTF-8"?>
ttp://struts.apache.org/dtds/struts-config_1_2.dtd">http://struts.apache.org/dtds/struts-config_1_2.dtd">


 
 
     type="com.hb.shop.web.form.AdminLoginForm" />
     type="com.hb.shop.web.form.AddTypeForm" />
     type="com.hb.shop.web.form.MemRegisterForm" />
     type="com.hb.shop.web.form.MemLoginForm" />
     type="com.hb.shop.web.form.ValidateForm" />
     type="com.hb.shop.web.form.AddGoodsForm" />
   
     
     
     
     
   
   
     
     
     
   
   
     
     
     
     
     
     
     
   
   
     
     
   
   
     
     
     
     
     
     
     
   
   
     
     
     
   
   
     
     
     
   
   
   
   
   
  
    

 
 
     redirect="true" />
     redirect="true" />
     redirect="true" />
     redirect="true" />
     redirect="true" />
     path="/simplecaptchaError.jsp" />

 

 

  <!-- cy --&gt
  <!--   type="org.springframework.web.struts.DelegatingActionProxy">
   
  

  --&gt
     input="/jsp/admin/adminLogin.html" name="adminLoginForm"
   path="/adminLogin" scope="request"
   type="org.springframework.web.struts.DelegatingActionProxy">
   
   
  

     input="/jsp/admin/goods/addType.jsp" name="addTypeForm"
   path="/addType" scope="request"
   type="org.springframework.web.struts.DelegatingActionProxy">
       redirect="true">
   
       redirect="true">
   
  

     name="addTypeForm" scope="request" parameter="method"
   type="org.springframework.web.struts.DelegatingActionProxy">
       path="/jsp/admin/listAllTypes.jsp">
   
   
   
  

     name="addGoodsForm" scope="request" parameter="method"
   type="org.springframework.web.struts.DelegatingActionProxy">
   
   
   
   
  
  
     type="org.springframework.web.struts.DelegatingActionProxy">
   
  
  
     type="org.springframework.web.struts.DelegatingActionProxy">
   
  
  
     type="org.springframework.web.struts.DelegatingActionProxy">
   
   
   
   
  
  
     type="org.springframework.web.struts.DelegatingActionProxy">
   
   
   
   
   
  
  <!-- cy --&gt

  <!-- ypf --&gt
     name="memRegisterForm" path="/memRegister" scope="request"
   type="org.springframework.web.struts.DelegatingActionProxy" />
     name="memLoginForm" path="/memLogin" scope="request"
   type="org.springframework.web.struts.DelegatingActionProxy"
   validate="false" />
     name="validateForm" path="/validate" scope="request"
   type="com.hb.shop.web.action.ValidateAction" validate="false" />
          attribute="regForm"
      input="/reg.jsp"
      name="regForm"
      path="/reg"
      scope="request"
      type="org.springframework.web.struts.DelegatingActionProxy" />
          attribute="loginForm"
      input="/login.jsp"
      name="loginForm"
      path="/login"
      scope="request"
      type="org.springframework.web.struts.DelegatingActionProxy" />
   
   
          path="/add"
     parameter="add"
     type="org.springframework.web.struts.DelegatingActionProxy" />
           path="/delete"
     parameter="delete"
     type="org.springframework.web.struts.DelegatingActionProxy" />
 
         path="/addNum"
     parameter="addNum"
     type="org.springframework.web.struts.DelegatingActionProxy" />
           path="/reduceNum"
     parameter="reduceNum"
     type="org.springframework.web.struts.DelegatingActionProxy" />
   
   
   
          attribute="deliverAddressInfoForm"
      input="balance.jsp"
      name="deliverAddressInfoForm"
      path="/deliverAddressInfo"
      scope="request"
      type="org.springframework.web.struts.DelegatingActionProxy" />
          attribute="submitOrderForm"
      input="/balance.jsp"
      name="submitOrderForm"
      path="/submitOrder"
      scope="request"
      type="org.springframework.web.struts.DelegatingActionProxy" />
          attribute="memberInfoForm"
      input="/member/editMyInfo.jsp"
      name="memberInfoForm"
      path="/memberInfo"
      scope="request"
      type="org.springframework.web.struts.DelegatingActionProxy" />
          attribute="emailInfoForm"
      input="/member/emailEdit.jsp"
      name="emailInfoForm"
      path="/emailInfo"
      scope="request"
      type="org.springframework.web.struts.DelegatingActionProxy" />
          attribute="nameInfoForm"
      input="/member/nameEdit.jsp"
      name="nameInfoForm"
      path="/nameInfo"
      scope="request"
      type="org.springframework.web.struts.DelegatingActionProxy" />
          attribute="passwordInfoForm"
      input="/member/passwordEdit.jsp"
      name="passwordInfoForm"
      path="/passwordInfo"
      scope="request"
      type="com.hb.shop.web.action.PasswordInfoAction" />
          attribute="testForm"
      input="/test.jsp"
      name="testForm"
      path="/test"
      scope="request"
      type="shop.web.action.TestAction" />

  
  <!-- ypf --&gt

 

 

   className="org.springframework.web.struts.ContextLoaderPlugIn">
     property="contextConfigLocation" />
 
 
    value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
  
 



3.spring配置文件:applicationContext.xml

<?xml version="1.0" encoding="UTF-8"?>
ttp://www.springframework.org/dtd/spring-beans.dtd">http://www.springframework.org/dtd/spring-beans.dtd">


 <!--注入BEAN--&gt
 

   class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
  
   
  
  
   
    com/hb/shop/modules/Admin.hbm.xml
    com/hb/shop/modules/Stocks.hbm.xml
    com/hb/shop/modules/Member.hbm.xml
    com/hb/shop/modules/Type.hbm.xml
    com/hb/shop/modules/Buyer.hbm.xml
    com/hb/shop/modules/Shoppinglist.hbm.xml
    com/hb/shop/modules/Goods.hbm.xml
    com/hb/shop/modules/Shoporder.hbm.xml
   
  
  
   
    
     org.hibernate.dialect.Oracle9Dialect
    
   
  

 
   class="org.apache.commons.dbcp.BasicDataSource">
  
   oracle.jdbc.driver.OracleDriver
  
  
   jdbc:oracle:thin:@192.168.122.184:1521:orcl
  
  
   pet
  
  
   pet
  
 

 <!-- cy --&gt
   class="com.hb.shop.web.action.AdminLoginAction">
  
   
  
 

   class="com.hb.shop.web.action.AddTypeAction">
  
   
  
 

   class="com.hb.shop.web.action.EditTypeAction">
  
   
  
 


   class="com.hb.shop.web.action.AddGoodsAction">
  
   
  
  
   
  
 

   class="com.hb.shop.web.action.ListGoodsByTypeAction">
  
   
  
 
 
   class="com.hb.shop.web.action.LookGoodsAction">
  
   
  
 
   class="com.hb.shop.web.action.DealOrderAction">
  
   
  
  
   
  
 
 
   class="com.hb.shop.web.action.DealMemberAction">
  
   
  
 
 <!-- cy --&gt

 <!-- ypf --&gt

 <!--   class="com.hb.shop.web.action.MemRegisterAction" abstract="false"
  singleton="true" lazy-init="default" autowire="default"
  dependency-check="default">
  
  
  
  
 --&gt
   abstract="false" singleton="true" lazy-init="default"
  autowire="default" dependency-check="default">
  
   
  
 
   class="com.hb.shop.web.action.LoginAction" abstract="false"
  singleton="true" lazy-init="default" autowire="default"
  dependency-check="default">
  
   
  
 
   class="com.hb.shop.web.action.MemLoginAction" abstract="false"
  singleton="true" lazy-init="default" autowire="default"
  dependency-check="default">
  
   
  
 
 <!--ypf--&gt
   abstract="false" singleton="true" lazy-init="default"
  autowire="default" dependency-check="default">
  
   
  
 
<!-- /nameInfo  com.hb.shop.web.action.NameInfoAction--&gt
  abstract="false" singleton="true" lazy-init="default"
  autowire="default" dependency-check="default">
  
   
  

  abstract="false" singleton="true" lazy-init="default"
  autowire="default" dependency-check="default">
  
   
  

     abstract="false" singleton="true" lazy-init="default"
  autowire="default" dependency-check="default">
  
   
  
 
   abstract="false" singleton="true" lazy-init="default"
  autowire="default" dependency-check="default">
  
   
  
  
   
  
 
   abstract="false" singleton="true" lazy-init="default"
  autowire="default" dependency-check="default">
  
   
  
 
   abstract="false" singleton="true" lazy-init="default"
  autowire="default" dependency-check="default">
  
   
  
 
   abstract="false" singleton="true" lazy-init="default"
  autowire="default" dependency-check="default">
  
   
  
 
   abstract="false" singleton="true" lazy-init="default"
  autowire="default" dependency-check="default">
  
   
  
 
   abstract="false" singleton="true" lazy-init="default"
  autowire="default" dependency-check="default">
  
   
  
 
 
 
   class="com.hb.shop.web.action.DeliverAddressInfoAction"
  abstract="false" singleton="true" lazy-init="default"
  autowire="default" dependency-check="default">
  
   
  
 

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/9474419/viewspace-473075/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/9474419/viewspace-473075/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值