ASP.NET MVC 1.0 + spring.net 1.2.0.20288 + NHibernate 2.0.1.4000整合笔记(二)——spring.net配置
spring.net 配置 :
将下图中的DLL,添加引用到CMS.MVCWeb中:
在web.config中加入以下代码:
1、在<configuration> -> <configSections>节点加入:
2、在<configuration>中加入:
3、在<configuration> -> <system.web> -> <httpHandlers>节点加入:
4、在<configuration> -> <system.web> -> <httpModules>节点加入:
5、在CMS.App类库中新建两个XML文件:
web_business.xml和web_web.xml
web_web.xml:
web_business.xml:
spring.net 配置完成,下面进行注入测试
7、在CMS.IBLL类库中添加一个ITestBLL接口
CMS.BLL类库添加实现
把CMS.BLL类库和CMS.IBLL类库添加到CMS.Web引用
web_web.xml:
web_business.xml:
Default.aspx.cs:
测试代码添加完成~以下是运行效果:
源码下载:
点击这里
将下图中的DLL,添加引用到CMS.MVCWeb中:
在web.config中加入以下代码:
1、在<configuration> -> <configSections>节点加入:
Code
2、在<configuration>中加入:
Code
3、在<configuration> -> <system.web> -> <httpHandlers>节点加入:
<!--spring.net 配置节点-->
<add verb="*" path="*.aspx" type="Spring.Web.Support.PageHandlerFactory, Spring.Web"/>
<!--spring.net 配置节点-->
<add verb="*" path="*.aspx" type="Spring.Web.Support.PageHandlerFactory, Spring.Web"/>
<!--spring.net 配置节点-->
4、在<configuration> -> <system.web> -> <httpModules>节点加入:
<!--spring.net 配置节点-->
<add name="Spring" type="Spring.Context.Support.WebSupportModule, Spring.Web"/>
<!--spring.net 配置节点-->
<add name="Spring" type="Spring.Context.Support.WebSupportModule, Spring.Web"/>
<!--spring.net 配置节点-->
5、在CMS.App类库中新建两个XML文件:
web_business.xml和web_web.xml
web_web.xml:
<?xml version="1.0" encoding="utf-8" ?>
<!-- WEB层的页面对像定义 -->
<objects xmlns='http://www.springframework.net'>
</objects>
<!-- WEB层的页面对像定义 -->
<objects xmlns='http://www.springframework.net'>
</objects>
web_business.xml:
<?xml version="1.0" encoding="utf-8" ?>
<!-- 业务层的对像定义 DAO & Manager -->
<objects xmlns='http://www.springframework.net'>
</objects>
6、把web_web.xml和web_business.xml都设置成“嵌入的资源”并将CMS.App添加到CMS.Web引用中:<!-- 业务层的对像定义 DAO & Manager -->
<objects xmlns='http://www.springframework.net'>
</objects>
spring.net 配置完成,下面进行注入测试
7、在CMS.IBLL类库中添加一个ITestBLL接口
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CMS.IBLL
{
public interface ITestBLL
{
void Write();
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CMS.IBLL
{
public interface ITestBLL
{
void Write();
}
}
CMS.BLL类库添加实现
Code
把CMS.BLL类库和CMS.IBLL类库添加到CMS.Web引用
web_web.xml:
Code
web_business.xml:
Code
Default.aspx.cs:
Code
测试代码添加完成~以下是运行效果:
源码下载:
点击这里