用JSF+Spring+IBatis搭建一个简单的框架

在实习的时候公司要求写一个图书管理系统,最后我们小组还是决定用JSF+Spring+IBatis来实现。虽然项目太小Spring基本没派上用处(无非就是在中间转接了一下),但是很有成就感的,怎么说我们的项目都是投入使用了而其他组的(只用了纯JSF)都没能跑起来,哈哈。

web.xml:关键是插入Spring的监听
xml 代码
  1. <listener>  
  2.         <listener-class>  
  3.             org.apache.myfaces.webapp.StartupServletContextListener   
  4.         </listener-class>  
  5.     </listener>  
  6.     <listener>  
  7.         <listener-class>  
  8.             org.springframework.web.context.ContextLoaderListener   
  9.         </listener-class>  
  10.     </listener>  

Spring配置文件applicationContext.xml:这里是把IBatis的数据源写在Spring的文件中,使Spring和IBatis结合起来

xml 代码
  1. <!-- dateSource -->  
  2.     <bean id="dataSource"  
  3.         class="org.apache.commons.dbcp.BasicDataSource"  
  4.         destroy-method="close">  
  5.         <property name="driverClassName">  
  6.             <value>com.mysql.jdbc.Driver</value>  
  7.         </property>  
  8.         <property name="url">  
  9.             <value>jdbc:mysql://192.168.102.19/bookadmin</value>  
  10.         </property>  
  11.         <property name="username">  
  12.             <value>bookadmin</value>  
  13.         </property>  
  14.         <property name="password">  
  15.             <value>123456</value>  
  16.         </property>  
  17.     </bean>  
  18.   
  19.   
  20.     <!-- sqlMapClient -->  
  21.     <bean id="sqlMapClient"  
  22.         class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">  
  23.         <property name="configLocation">  
  24.             <value>  
  25.                 classpath:thiz/ks/bookadmin/dao/ibatis/SqlMapConfig.xml   
  26.             </value>  
  27.         </property>  
  28.     </bean>  

IBatis的SqlMap文件SqlMapConfig.xml和JSF的配置文件faces-config.xml:该怎么写还是怎么写

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值