github:https://github.com/lakeslove/SSM

项目的目录结构如下

首先,配置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" version="3.0">
<display-name>SSM</display-name> <!-- session和cookie的配置 -->
<session-config>
<session-timeout>40</session-timeout>
<cookie-config>
<name>SSM</name>
<http-only>true</http-only>
</cookie-config>
</session-config> <!-- 访问的首页的配置 -->
<welcome-file-list>
<welcome-file>index.htm</welcome-file>
</welcome-file-list> <!-- springMVC的拦截器配置,这个是重点 -->
<servlet>
<servlet-name>spring-dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value></param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring-dispatcher</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping> <context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/classes/spring-context.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener> <!-- 防止乱码的配置,这个配置的mapping一定要在loginFilter之前,否则loginFilte里乱码 -->
<filter>
<filter-name>encodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<servlet-name>spring-dispatcher</servlet-name>
</filter-mapping> <!-- 自定义的登录过滤器 -->
<filter>
<display-name>LoginFilter</display-name>
<filter-name>LoginFilter</filter-name>
<filter-class>com.lx.filter.LoginFilter</filter-class>
<init-param>
<param-name>indexPath</param-name>
<param-value>index.htm</param-value>
</init-param>
<init-param>
<param-name>ignoreList</param-name>
<param-value></param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>LoginFilter</filter-name>
<url-pattern>*.htm</url-pattern>
</filter-mapping> <!-- 错误页面,平常多用静态页面,这里用了动态页面,目的是为了对异常进行动态的处理 -->
<error-page>
<error-code>500</error-code>
<location>/testError.htm</location>
</error-page>
<error-page>
<exception-type>java.lang.Throwable</exception-type>
<location>/testError.htm</location>
</error-page> <!-- 测试用的Servlet -->
<servlet>
<description></description>
<display-name>TestServlet</display-name>
<servlet-name>TestServlet</servlet-name>
<servlet-class>com.lx.servlets.TestServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>TestServlet</servlet-name>
<url-pattern>/TestServlet.htm</url-pattern>
</servlet-mapping> <!-- 测试用的监听器 -->
<listener>
<listener-class>com.lx.listeners.TestListenser</listener-class>
</listener>
</web-app>

springMVC和spring的配置文件:spring-context.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:tx="http://www.springframework.org/schema/tx"
xmlns:p="http://www.springframework.org/schema/p" xmlns:task="http://www.springframework.org/schema/task"
xmlns:cache="http://www.springframework.org/schema/cache" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.2.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.2.xsd
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task-4.2.xsd
http://www.springframework.org/schema/cache
http://www.springframework.org/schema/cache/spring-cache-4.2.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.2.xsd"> <context:property-placeholder location="classpath:system.properties" />
<context:annotation-config />
<!-- 使用注解管理事务 -->
<tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/>
<cache:annotation-driven cache-manager="cacheManager"/>
<task:executor id="taskExecutor" pool-size="1-20" queue-capacity="30" keep-alive="60" />
<task:scheduler id="scheduler" pool-size="1" />
<task:annotation-driven executor="taskExecutor" scheduler="scheduler" />
<!-- 需要扫描的包 start-->
<context:component-scan base-package="com.lx.controllers" />
<context:component-scan base-package="com.lx.services.impl" />
<!-- 需要扫描的包 end --> <mvc:annotation-driven />
<!-- 数据验证 start -->
<!-- 数据验证 end -->
<!-- viewResolver start -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="order" value="2" />
<property name="prefix">
<value>/WEB-INF/view/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean> <!-- tiles 配置开始 -->
<bean id="viewResolver"
class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="order" value="1" />
<property name="viewClass">
<value>
org.springframework.web.servlet.view.tiles3.TilesView
</value>
</property>
</bean> <bean id="tilesConfigurer"
class="org.springframework.web.servlet.view.tiles3.TilesConfigurer">
<property name="definitions">
<list>
<value>/WEB-INF/classes/tilesPublic.xml</value>
</list>
</property>
</bean>
<!-- tiles 配置结束 -->
<!-- viewResolver end --> <!-- hibernate start-->
<!-- jndi start -->
<!--
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName">
<value>${db.jndiname}</value>
</property>
</bean>
-->
<!-- jndi end --> <bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource"
destroy-method="close">
<property name="url" value="${db.url}"></property>
<property name="driverClassName" value="${db.driver}"></property>
<property name="username" value="${db.username}"></property>
<property name="password" value="${db.password}"></property>
<property name="maxTotal" value="30" />
<property name="maxIdle" value="20" />
<property name="minIdle" value="5" />
<property name="initialSize" value="5" />
<property name="maxWaitMillis" value="-1" />
<property name="timeBetweenEvictionRunsMillis" value="120000" />
<property name="minEvictableIdleTimeMillis" value="300000" />
<property name="poolPreparedStatements" value="true" />
<property name="removeAbandonedOnBorrow" value="true" />
<property name="validationQuery">
<value>select 1 from dual</value>
</property>
</bean> <!-- 使用MyBatis-spring的sqlSessionFactory来代替MyBatis本身的sqlSessionFactory -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="configLocation" value="classpath:mybatis.xml" />
</bean> <!-- 使用MyBatis-spring的sqlSessionTemplate来包装sqlSessionFactory -->
<bean id="sqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate" scope="prototype">
<constructor-arg index="0" ref="sqlSessionFactory" />
<!-- <constructor-arg index="1" value="BATCH" /> -->
</bean> <!-- 事务管理 -->
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean> <!-- 采用自动扫描方式创建mappper bean -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com"/>
<property name="sqlSessionTemplateBeanName" value="sqlSessionTemplate"/>
<property name="annotationClass" value="org.springframework.stereotype.Repository"/>
</bean> <!-- 国际化(多语言对应) 开始 -->
<bean id="messageSource"
class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basenames">
<list>
<value>message_error</value>
<value>message_generic</value>
<value>message_validate</value>
</list>
</property>
<property name="useCodeAsDefaultMessage" value="false" />
<property name="defaultEncoding" value="UTF-8" />
<property name="cacheSeconds" value="600" />
</bean>
<!-- 国际化(多语言对应) 结束--> <!-- 异常处理 start -->
<!-- <bean class="com.lx.exceptions.ExceptionHandler" /> -->
<bean id="exceptionResolver"
class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
<property name="exceptionMappings">
<props>
<prop key="org.springframework.web.multipart.MaxUploadSizeExceededException">error_fileupload</prop>
</props>
</property>
</bean>
<!-- 异常处理 end --> <!-- 缓存支持 start -->
<bean id="cacheManager" class="org.springframework.cache.support.SimpleCacheManager">
<property name="caches">
<set>
<bean
class="org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean"
p:name="masterCache" />
</set>
</property>
</bean>
<!-- 缓存支持 end --> <!-- 文件上传限制 开始 -->
<bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="defaultEncoding" value="UTF-8" />
<property name="maxUploadSize" value="10485760" />
<property name="maxInMemorySize" value="1048576" />
</bean>
<!-- 文件上传限制 结束 --> <!-- velocityEngine start-->
<bean id="velocityEngine"
class="org.springframework.ui.velocity.VelocityEngineFactoryBean">
<property name="resourceLoaderPath">
<value>classpath:velocity</value>
</property>
<property name="velocityProperties">
<props>
<prop key="file.resource.loader.cache">false</prop>
<prop key="file.resource.loader.modificationCheckInterval">3</prop>
<prop key="input.encoding">UTF-8</prop>
<prop key="output.encoding">UTF-8</prop>
</props>
</property>
</bean>
<!-- velocityEngine end --> <!-- sendEmail start -->
<!-- 解除默认的单例模式,设置scope="prototype" -->
<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl" scope="prototype">
<property name="host" value="${mail.host}" />
<property name="username" value="${mail.username}" />
<property name="password" value="${mail.password}" />
<property name="javaMailProperties">
<props>
<prop key="mail.smtp.auth">${mail.smtp.auth}</prop>
<prop key="mail.smtp.timeout">${mail.smtp.timeout}</prop>
<prop key="mail.smtp.port">${mail.smtp.port}</prop>
</props>
</property>
</bean>
<!-- sendEmail end --> <!-- IOC demo start -->
<!-- springFrome initiate check start -->
<!-- <bean class="com.lx.utils.CheckConfigs">
<property name="dbUrl" value="${db.url}" />
<property name="userDao">
<bean class="com.lx.daos.impl.UserDaoImpl" />
</property>
</bean> -->
<!-- initiate check end --> <!-- 在过滤器中注入service start-->
<bean id="userService" class="com.lx.services.impl.UserServiceImpl"></bean>
<!-- 在过滤器中注入service end--> <!-- IOC demo end--> <!-- AOP demo start -->
<!-- 切面类 -->
<bean id="appendLogsByAOP" class="com.lx.utils.AppendLogsByAOP"/>
<!-- 切入点 -->
<aop:config>
<aop:pointcut id="afterMethodPoint" expression="execution(* com.lx.controllers.publics.*Controller.*(..))"/>
<aop:aspect id = "appendLogs" ref="appendLogsByAOP">
<aop:before method="logOutputBeforeMethod" pointcut="execution(* com.lx.controllers.publics.*Controller.*(..))"/>
<aop:after-throwing method="logOutputAfterThrows" pointcut="execution(* com.lx.controllers.publics.*Controller.*(..))"/>
<!-- 可以用 pointcut-ref来指代相同的pointcut-->
<aop:after-returning method="logOutputAfterReturn" pointcut-ref="afterMethodPoint"/>
<aop:after method="logOutputAfterMethod" pointcut-ref="afterMethodPoint"/>
</aop:aspect>
</aop:config>
<!-- AOP demo end --> </beans>

SSM整理笔记3——配置解析的更多相关文章

  1. SSM整理笔记2——jar包整理

    github:https://github.com/lakeslove/SSM 需要的jar包 springMVC和spring: spring.RELEASE.jar spring.RELEASE. ...

  2. SSM整理笔记1——SSM网站初步功能设计

    前言 因为公司里一直用Hibernate,但是现在Mybatis是趋势,所以搭建一个Mybatis的网站框架,目的是:1摸清其功能特点,2为以后的项目增加框架选择(以前只用hibernate或者Spr ...

  3. 运维开发笔记整理-django日志配置

    运维开发笔记整理-django日志配置 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.Django日志 Django使用python内建的logging模块打印日志,Pytho ...

  4. nsq源码阅读笔记之nsqd(一)——nsqd的配置解析和初始化

    配置解析 nsqd的主函数位于apps/nsqd.go中的main函数 首先main函数调用nsqFlagset和Parse进行命令行参数集初始化, 然后判断version参数是否存在,若存在,则打印 ...

  5. xmpp整理笔记:xmppFramework框架的导入和介绍

    一个将要开发xmpp的项目,建议在项目刚创建就导入框架,这样可以避免一些自己操作失误造成不必要的损失. xmpp中最常用的框架就是 xmppFrameWork 往期回顾: xmpp整理笔记:环境的快速 ...

  6. SSM整合笔记

    SSM整合笔记 1,创建maven项目 创建maven项目过程省略 ps:如果创建完maven项目之后项目报错,可能是没有配置Tomcat 2,在pom.xml里面导入相应的jar的依赖 <pr ...

  7. xmpp整理笔记:发送图片信息和声音信息

    图片和音频文件发送的基本思路就是: 先将图片转化成二进制文件,然后将二进制文件进行base64编码,编码后成字符串.在即将发送的message内添加一个子节点,节点的stringValue(节点的值) ...

  8. xmpp整理笔记:聊天信息的发送与显示

    任何一个信息的发送都需要关注两个部分,信息的发出,和信息在界面中的显示 往期回顾: xmpp整理笔记:环境的快速配置(附安装包)  http://www.cnblogs.com/dsxniubilit ...

  9. xmpp整理笔记:用户网络连接及好友的管理

    xmpp中的用户连接模块包括用户的上线与下线信息展现,用户登录,用户的注册: 好友模块包括好友的添加,好友的删除,好友列表的展示. 在xmpp中 负责数据传输的类是xmppStream,开发的过程中, ...

随机推荐

  1. 【SVN】http和https的区别

    导读:输入网址的时候,经常输入http://什么什么的,但http是什么,一直都不知道.然后,这回在SVN的学习中,又出现了http和https,而且还有说https的8443端口相对优越,我就在想, ...

  2. sql自动审核工具-inception

    [inception使用规范及说明文档](http://mysql-inception.github.io/inception-document/usage/)[代码仓库](https://githu ...

  3. 【Luogu】P1972HH的项链(链表+树状数组)

    题目链接 难题,所以会讲得细一些. 首先我们想如何统计区间[l,r]内不同贝壳的个数. 第一个思路就是线段树/树状数组,query(1,r)-query(1,l-1)对不对? 然而这样是不对的. 然后 ...

  4. 转载: 找不到MSVCR90.dll、Debug vs Release及cppLapack相关

    今天调试程序时出现了,找不到MSCVR90.dll的错误,最好查找到了解决办法,原文链接如下:   http://hi.baidu.com/wpzhao/blog/item/72dc08f77ce9b ...

  5. Spring-IOC源码解读3-依赖注入

    当容器已经载入了BeanDefinition的信息完成了初始化,我们继续分析依赖注入的原理,需要注意的是依赖注入是用户第一次向IOC容器获取Bean的时候发生的,这里有个例外,那就是如果用户在Bean ...

  6. Centos 安装Python3的方法

    由于centos7原本就安装了Python2,而且这个Python2不能被删除,因为有很多系统命令,比如yum都要用到. [root@VM_105_217_centos Python-3.6.2]# ...

  7. centos7 安装teamviewer 报错libQt5WebKitWidgets.so.5()(64bit)

    https://blog.csdn.net/kenny_lz/article/details/78884603

  8. 顿悟:Linux是拿来用的,不是拿来折腾的

    Linux是拿来用的,而不是折腾其本身.相信这个道理不少聪明人(实用主义者)都明白,然而总是有那么一群人拿Linux去安装各种发行版.研究Linux命令.配置桌面.美化桌面.研究各种wm/DE.永无止 ...

  9. 关于css虚线

    今天遇到几个虚线效果,不能一下子反应过来具体属性. 一.dashed和dotted的区别 首先是dashed和dotted都是指“虚线”,但是两者显示的效果不尽相同. 从字面意思来看, dashed: ...

  10. 洛谷 P2831 愤怒的小鸟

    P2831 愤怒的小鸟 题目描述 Kiana 最近沉迷于一款神奇的游戏无法自拔. 简单来说,这款游戏是在一个平面上进行的. 有一架弹弓位于 (0,0)(0,0) 处,每次 Kiana 可以用它向第一象 ...