ssm通讯录管理系统--1

来源:互联网 发布:java表示一个数的次方 编辑:程序博客网 时间:2024/05/20 21:19


程序结构



数据库结构




相关配置信息


springContext.xml

<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:context="http://www.springframework.org/schema/context"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/tx  http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context-3.0.xsd"><!-- 引入我们的database.properties,hibernate.properties文件 -->    <bean id="property" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">         <property name="locations">             <list>                <value>classpath:database.properties</value><!-- classpath代表类路径,如src下面的文件 -->             </list>         </property>    </bean>         <!-- 启用自动扫描 --><context:component-scan base-package="com.ssm.*">  <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller" /><!-- 排除注解为controller的类型 --></context:component-scan><!-- 定义使用C3P0连接池的数据源 --><bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"><!-- 指定连接数据库的JDBC驱动 --><property name="driverClass"> <value>${mysql.driver_class}</value> </property><!-- 连接数据库所用的URL --><property name="jdbcUrl"><value>${mysql.connection.url}</value></property><!-- 连接数据库的用户名 --><property name="user"><value>${mysql.connection.username}</value></property><!-- 连接数据库的密码 --><property name="password"><value>${mysql.connection.password}</value></property><!-- 设置数据库连接池的最大连接数 --><property name="maxPoolSize"><value>30</value></property><!-- 设置数据库连接池的最小连接数 --><property name="minPoolSize"><value>2</value></property><!-- 设置数据库连接池的初始化连接数 --><property name="initialPoolSize"><value>2</value></property><!-- 设置数据库连接池的连接的最大空闲时间,单位为秒 --><property name="maxIdleTime"><value>10</value></property></bean><!-- 配置SqlSessionFactoryBean --><bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"><property name="dataSource" ref="dataSource"/><property name="configLocation" value="classpath:mybatis.xml"/><!-- mapper和resultmap配置路径 --><property name="mapperLocations"><list><value>classpath:com/ssm/mapper/*.xml</value></list></property></bean><!-- 自动扫描mapper接口,注入sqlsessionfactory --><bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"><property name="basePackage" value="com.ssm.mapper"/></bean><!-- 开启 mybatis事务--> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"><property name="dataSource" ref="dataSource" /></bean><tx:annotation-driven transaction-manager="transactionManager"  proxy-target-class="true"/></beans>


springmvc.xml

<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"xmlns:context="http://www.springframework.org/schema/context"xmlns:mvc="http://www.springframework.org/schema/mvc"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context-3.0.xsdhttp://www.springframework.org/schema/mvchttp://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"><!-- 第二步,建立一个springmvc.xml文件在src下 --><!-- 扫描该包下的注解 --><context:component-scan base-package="com.ssm.controller"/><!-- 第三步:annotation默认的方法映射适配器 ,视图解析器,类似于action--><bean id="handlerMapping" class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" /><!-- 寻找类 --><bean id="handlerAdapter" class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" /><!-- 根据url找方法 -->    <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"><property name="prefix" value="/WEB-INF/pages/"></property><property name="suffix" value=".jsp"></property></bean></beans>

mybatis.xml
<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN"  "http://mybatis.org/dtd/mybatis-3-config.dtd"><configuration><!-- 配置实体类的别名 --><typeAliases><typeAlias type="com.ssm.domain.User" alias="user"/></typeAliases><!-- 这里指的是你要简写的那个Bean的目录,别名就是类名,为了简便不在写 resultType="com.mybatis.test.User 这样直接写resultType="User" --></configuration>


web.xml
<?xml version="1.0" encoding="UTF-8"?><web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">  <display-name>newssm</display-name>    <welcome-file-list>    <welcome-file>index.jsp</welcome-file>  </welcome-file-list>      <!-- 第一步:配置Springmvc核心控制器      servlet主要就是处理页面传过来的表单数据,页面上的form的action指向到web.xml中,           然后在XML中对称节点中找到对应的servlet类去执行你的处理方法.--><servlet><servlet-name>spring_mvc</servlet-name><servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class><init-param><param-name>contextConfigLocation</param-name><param-value>classpath:springmvc.xml</param-value></init-param><load-on-startup>1</load-on-startup><!-- 立马启动servlet --></servlet><!-- 第一步:servlet-mapping主要是截获请求的,     如果你的url-pattern定义的是路径,那么以后所有对这个路径下资源的请求都会由servlet-name中定义的servlet处理;     如果你的url-pattern定义的是资源格式例如*.do等,那么对于所有符合这种格式的资源的请求都由指定的servlet处理。 --><servlet-mapping><servlet-name>spring_mvc</servlet-name><url-pattern>/</url-pattern></servlet-mapping><!-- 加载Spring容器配置 --><listener><listener-class>org.springframework.web.context.ContextLoaderListener</listener-class></listener><!-- 设置Spring容器加载配置文件路径 --><context-param><param-name>contextConfigLocation</param-name><param-value>classpath:springContext.xml</param-value></context-param><!-- 由Spring载入的Log4j配置文件位置 --><context-param>       <param-name>log4jConfigLocation</param-name>       <param-value>classpath:log4j.properties</param-value></context-param><!-- Spring默认刷新Log4j配置文件的间隔,单位为millisecond --><context-param>       <param-name>log4jRefreshInterval</param-name>       <param-value>60000</param-value></context-param><!-- Web 项目 Spring 加载 Log4j 的监听  --><listener> <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class> </listener><!-- 乱码过滤器 --><filter>          <filter-name>encodingFilter</filter-name>          <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>          <async-supported>true</async-supported>          <init-param>              <param-name>encoding</param-name>              <param-value>UTF-8</param-value>          </init-param>      </filter>    <filter-mapping>  <span style="white-space:pre"></span><filter-name>encodingFilter</filter-name>  <span style="white-space:pre"></span><url-pattern>/*</url-pattern>  <span style="white-space:pre"></span></filter-mapping>  </web-app>


原创粉丝点击