SSI的整合配置文件

1.配置Spring配置文件

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:aop="http://www.springframework.org/schema/aop"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:core="http://cxf.apache.org/core"
	xmlns:tx="http://www.springframework.org/schema/tx"
	
	xmlns:jaxws="http://cxf.apache.org/jaxws"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
		http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
		http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
		http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
	 	http://cxf.apache.org/jaxws
	 	http://cxf.apache.org/schemas/jaxws.xsd">

	<bean id="propertyPlaceholderConfigurer"
		class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
		<property name="location">
			<value>classpath:Mysql.properties</value>
		</property>
	</bean>
	<bean class="org.springframework.jdbc.datasource.DriverManagerDataSource" id="dataSource">
		<property name="driverClassName" value="${driver}"></property>
		<property name="url" value="${url}"></property>
		<property name="username" value="${username}"></property>
		<property name="password" value="${password}"></property>
	</bean>
	<bean class="org.springframework.orm.ibatis.SqlMapClientFactoryBean" id="sqlMapClientFactoryBean">
		<property name="configLocation" value="classpath:ibatis-config.xml"></property>
		<property name="dataSource" ref="dataSource"></property>
	</bean>
	<bean class="org.springframework.orm.ibatis.SqlMapClientTemplate" id="sqlMapClientTemplate">
		<property name="sqlMapClient" ref="sqlMapClientFactoryBean"></property>
		
	</bean>
	<bean class="com.zhang.DAO.impl.UserDAOImpl" id="userDAOImpl">
		<property name="sqlMapClientTemplate" ref="sqlMapClientTemplate"></property>
	</bean>
	<bean class="com.zhang.service.impl.UserServiceImpl" id="userServiceImpl">
		<property name="userDAOImpl" ref="userDAOImpl"></property>
	</bean>
</beans>

2 ibatis配置文件

<?xml version="1.0" encoding="UTF-8" ?>  
<!DOCTYPE sqlMapConfig        
    PUBLIC "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN"        
    "http://ibatis.apache.org/dtd/sql-map-config-2.dtd">  
<sqlMapConfig>       
    <sqlMap resource="UserMapping.xml" />  
</sqlMapConfig>

3mysql配置文件

driver=com.mysql.jdbc.Driver
url=jdbc:mysql://localhost:3306/homework?characterEncoding=utf-8
username=root
password=root

4 简单映射

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap        
    PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"        
    "http://ibatis.apache.org/dtd/sql-map-2.dtd">  
<sqlMap>   
    <select id="getUser" resultClass="com.zhang.pojo.Home_User">  
    	select * from homework_user;
    </select> 
    
</sqlMap>

5 mvc配置

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"  
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:beans="http://www.springframework.org/schema/beans"  
    xmlns:p="http://www.springframework.org/schema/p" 
    xmlns:aop="http://www.springframework.org/schema/aop"  
    xmlns:context="http://www.springframework.org/schema/context"  
    xsi:schemaLocation="http://www.springframework.org/schema/mvc 
    	http://www.springframework.org/schema/mvc/spring-mvc.xsd  
        http://www.springframework.org/schema/aop  
        http://www.springframework.org/schema/aop/spring-aop-3.2.xsd 
        http://www.springframework.org/schema/beans 
        http://www.springframework.org/schema/beans/spring-beans.xsd  
        http://www.springframework.org/schema/context 
        http://www.springframework.org/schema/context/spring-context.xsd">  
  
      
    <!-- SpringMVC配置 -->  
      
    <!-- 通过component-scan 让Spring扫描org.swinglife.controller下的所有的类,让Spring的代码注解生效 -->  
    <context:component-scan base-package="com.zhang.controller"></context:component-scan> 
     <!-- 配置SpringMVC的视图渲染器, 让其前缀为:/ 后缀为.jsp  将视图渲染到/page/<method返回值>.jsp中 -->  
    <beans:bean  
        class="org.springframework.web.servlet.view.InternalResourceViewResolver"  
        p:prefix="/" p:suffix=".jsp">  
    </beans:bean> 
  
</beans:beans>

6 web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns="http://xmlns.jcp.org/xml/ns/javaee"
	xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
	id="WebApp_ID" version="3.1">
	<display-name>ssi-zhangjingbo-20181123</display-name>
	<welcome-file-list>
		<welcome-file>index.html</welcome-file>
		<welcome-file>index.htm</welcome-file>
		<welcome-file>index.jsp</welcome-file>
		<welcome-file>default.html</welcome-file>
		<welcome-file>default.htm</welcome-file>
		<welcome-file>default.jsp</welcome-file>
	</welcome-file-list>
	<listener>
		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	</listener>
	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>classpath:Spring-config.xml</param-value>
	</context-param>
	<servlet>
		<servlet-name>mvc</servlet-name>
		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
		<init-param>
			<param-name>contextConfigLocation</param-name>
			<param-value>classpath:mvc-config.xml</param-value>

		</init-param>
		<load-on-startup>1</load-on-startup>
	</servlet>
	<servlet-mapping>
		<servlet-name>mvc</servlet-name>
		<url-pattern>/</url-pattern>
	</servlet-mapping>
</web-app>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值