Spring.net 在aps.net Web的配置复习
2015-06-13 18:20
507 查看
1.引入程序集Spring.Core,CommonLogging,Spring.Web
2.Web.Config的配置
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="spring">
<section name="context" type="Spring.Context.Support.WebContextHandler, Spring.Web"/>
<section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core"/>
</sectionGroup>
</configSections>
<spring>
<context>
<resource uri="config://spring/objects"/>
<resource uri="~/Config/BLL.xml"/>
</context>
<objects xmlns="http://www.springframework.net">
<object id="student" type="WebApplication5.Student, WebApplication5">
</object>
</objects>
</spring>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<httpHandlers>
</httpHandlers>
</system.web>
<system.webServer>
<modules>
<add name="Spring" type="Spring.Context.Support.WebSupportModule, Spring.Web"/>
</modules>
<handlers>
<add name="handle1" verb="*" path="*.aspx" type="Spring.Web.Support.PageHandlerFactory, Spring.Web"/>
</handlers>
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
BLL.XML
<?xml version="1.0" encoding="utf-8" ?>
<objects xmlns="http://www.springframework.net">
<object id="Teacher" type="WebApplication5.Teacher,WebApplication5">
</object>
</objects>
3. 客户端调用部分
IApplicationContext ctx = ContextRegistry.GetContext();
Student stu=ctx["Student"] as Student;
stu.SayHello();
2.Web.Config的配置
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="spring">
<section name="context" type="Spring.Context.Support.WebContextHandler, Spring.Web"/>
<section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core"/>
</sectionGroup>
</configSections>
<spring>
<context>
<resource uri="config://spring/objects"/>
<resource uri="~/Config/BLL.xml"/>
</context>
<objects xmlns="http://www.springframework.net">
<object id="student" type="WebApplication5.Student, WebApplication5">
</object>
</objects>
</spring>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<httpHandlers>
</httpHandlers>
</system.web>
<system.webServer>
<modules>
<add name="Spring" type="Spring.Context.Support.WebSupportModule, Spring.Web"/>
</modules>
<handlers>
<add name="handle1" verb="*" path="*.aspx" type="Spring.Web.Support.PageHandlerFactory, Spring.Web"/>
</handlers>
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
BLL.XML
<?xml version="1.0" encoding="utf-8" ?>
<objects xmlns="http://www.springframework.net">
<object id="Teacher" type="WebApplication5.Teacher,WebApplication5">
</object>
</objects>
3. 客户端调用部分
IApplicationContext ctx = ContextRegistry.GetContext();
Student stu=ctx["Student"] as Student;
stu.SayHello();
相关文章推荐
- spring中事务管理的几种方式
- 在eclipse中导入spring源码
- Struts1之编码问题
- Struts1之bean标签
- 在Spring MVC中,事务可以加在Controller层
- java 关于分页的实现
- Maven学习(二十六)-Maven新建项目的JDK版本类型问题
- Struts1之logic标签
- Java IO之PushbackInputStream类
- Struts1之html标签
- Maven学习(二十五)- Eclipse中不使用内嵌Maven
- java-String中的 intern()<转>
- MyBatis学习(十一)-MyBatis与Spring整合(一)
- Java设计模式——Proxy(代理)模式
- 通过Java反射在运行时修改TimerTask的执行周期并且立即生效
- ”好程序员训练营“——用eclipse调试程序
- 重踏学习Java路上_Day02(java 基础上)
- Spring [IoC]6 详解@Autowired、@Qualifier和@Required
- Java内部类详解
- path与classpath区别