zoukankan      html  css  js  c++  java
  • 转Spring.net web.config配置文件(经过整理和修改)

    注:此文只适用于WebForm,Winform中需要将HttpMoudles和HttpHandlers去掉

    转载地址:http://blog.163.com/fengzhisha0914@126/blog/static/15031478520113115718158/

    需要引入:spring.Aop,spring.core,spring.web,antlr.runtime,common.logging

    Web.config配置文件

    1. 添加Spring的SectionGroup

    View Code
    1 <sectionGroup name="spring">
    2       <section name="context" type="Spring.Context.Support.WebContextHandler, Spring.Web"/>
    3       <section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core"/>
    4 </sectionGroup>

    2. 添加HttpHandler配置

    View Code
    1 <add verb="*" path="*.aspx" type="Spring.Web.Support.PageHandlerFactory, Spring.Web"/>

    3. 添加HttpModule配置(如果不添加的话,会有异常)---注:此行一定要放到HttpModule的第一条,要不然会有报错,我也不知道为什么???那位大侠可告诉一下

    View Code
    1 <add name="Spring" type="Spring.Context.Support.WebSupportModule, Spring.Web"/>

    4. 最后配置如何依赖注入

    View Code
     1 <spring>
     2     <context>
     3       <resource uri="config://spring/objects"/>
     4     </context>
     5     <objects xmlns="http://www.springframework.net">
     6       <object type="Default.aspx">
     7         <property name="Service" ref="myService"/>
     8       </object>
     9       <object id="myService" type="Services.MyService, Services">
    10       </object>
    11     </objects>
    12   </spring>

    上面那个是定义在Web.config中的Spring节点的写法,下面这个更全一点

    <spring>

    <!--

    配置在Web.config中需要指定type

    <context type="Spring.Context.Support.XmlApplicationContext, Spring.Core">

    -->

    <!--配置在其他xml中不需要指定type-->

        <context>

          <!--<resource uri="config://spring/objects"/>(配置在Web.config中方法)-->

          <resource uri="~/spring.xml.config"/><!--指定其他配置文件-->

        </context>

  • 相关阅读:
    linux上mysql安装详细教程
    druid部署
    druid.io本地集群搭建 / 扩展集群搭建
    CentOS7.1.x+Druid 0.12 集群配置
    Python小项目四:实现简单的web服务器
    hadoop学习---运行第一个hadoop实例
    Hadoop集群完全分布式坏境搭建
    mysql备份与恢复
    mysql登录的三种方式
    nginx代理,负载均衡
  • 原文地址:https://www.cnblogs.com/smthts/p/2687740.html
Copyright © 2011-2022 走看看