基于Maven构建SSM+Druid+Bootstrap(AdminLTE)项目--简单示例

转自:https://blog.csdn.net/cyh1111/article/details/53641814

前言

最近在做一个小项目,基于Maven构建,框架使用现在主流的:SpringMVC(4.1)+Spring(4.1)+MyBatis(3.4.0),实现基本增删改查,页面国际化。数据源采用阿里开源的Druid,前端采用基于Bootstrap封装的模板AdminLTE(2.3.6)及Bootstrap的一些插件。MyBaits采用了另外一位博友提供的通用CRUD代码。
前段时间发过几篇文档,陆续有些朋友需要源码,今天有时间,将项目简化,源码发出。仅供学习!
文章地址:
http://blog.csdn.net/cyh1111/article/details/52961250
http://blog.csdn.net/cyh1111/article/details/52960233

效果

1、登陆
这里写图片描述
2、注册
这里写图片描述
3、主页
这里写图片描述
4、Modal 框 修改
这里写图片描述
5、操作消息提醒–2秒自动关闭
这里写图片描述

功能

1、Maven POM文件

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <groupId>com.cyh</groupId>
    <artifactId>SSM-Demo</artifactId>
    <packaging>war</packaging>
    <version>1.0.0.0</version>

    <name>SSM-Demo</name>
    <url>http://maven.apache.org</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <!-- libs -->
        <junit.version>4.11</junit.version>
        <jstl.version>1.2</jstl.version>
        <javaee-api.version>7.0</javaee-api.version>
        <cglib.version>3.2.2</cglib.version>
        <aspectjrt.version>1.8.0</aspectjrt.version>
        <aspectjweaver.version>1.8.0</aspectjweaver.version>
        <spring.version>4.1.7.RELEASE</spring.version>
        <mybatis-spring.version>1.3.0</mybatis-spring.version>
        <mybatis.version>3.4.0</mybatis.version>
        <log4j.version>1.2.17</log4j.version>
        <slf4j.version>1.7.21</slf4j.version>
        <fileupload.version>1.3.1</fileupload.version>
        <mysql.version>5.1.35</mysql.version>
        <druid.version>1.0.19</druid.version>
        <fastjson.version>1.2.11</fastjson.version>
        <gson.version>2.3.1</gson.version>

        <!--  
        <commons-lang.version>2.6</commons-lang.version>
        <commons-io.version>2.5</commons-io.version>
        <jdom.version>2.0.2</jdom.version>
        <activeMQ.version>5.11.4</activeMQ.version>
        <javassist.version>3.12.1.GA</javassist.version>
        <transaction.version>1.1</transaction.version>
        -->
    </properties>

    <!-- 依赖包集合 -->  
    <dependencies>  
        <!-- 1. junit 依赖 begin junit3.0使用编程方式运行,junit4.0使用注解方式运行  -->  
        <dependency>  
            <groupId>junit</groupId>  
            <artifactId>junit</artifactId>  
            <version>${junit.version}</version>  
        </dependency>  
        <!-- junit 依赖 end  -->  

        <!-- 2. Servlet web相关依赖 begin-->  
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-api</artifactId>
            <version>${javaee-api.version}</version>
        </dependency>

        <dependency>
            <groupId>jstl</groupId>
            <artifactId>jstl</artifactId>
            <version>${jstl.version}</version>
        </dependency>
        <!-- Servlet web相关依赖 end-->  

        <!-- 3. aspectjweaver 依赖 begin -->
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjweaver</artifactId>
            <version>${aspectjweaver.version}</version>
        </dependency>
        <!-- aspectjweaver 依赖 end -->

        <!-- 4. spring依赖  begin-->  
        <!-- spring核心依赖-->  
        <dependency>  
            <groupId>org.springframework</groupId>  
            <artifactId>spring-core</artifactId>  
            <version>${spring.version}</version>  
        </dependency>  

        <!-- spring ioc依赖 -->  
        <dependency>  
            <groupId>org.springframework</groupId>  
            <artifactId>spring-beans</artifactId>  
            <version>${spring.version}</version>  
        </dependency>  

        <!-- spring aop依赖 -->  
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aop</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <!-- spring 扩展依赖 -->  
        <dependency>  
            <groupId>org.springframework</groupId>  
            <artifactId>spring-context</artifactId>  
            <version>${spring.version}</version>  
        </dependency>  

        <!--spring dao层依赖-->  
        <dependency>  
            <groupId>org.springframework</groupId>  
            <artifactId>spring-jdbc</artifactId>  
            <version>${spring.version}</version>  
        </dependency>  
        <dependency>  
            <groupId>org.springframework</groupId>  
            <artifactId>spring-tx</artifactId>  
            <version>${spring.version}</version>  
        </dependency>  

        <!-- spring web相关依赖 -->  
        <dependency>  
            <groupId>org.springframework</groupId>  
            <artifactId>spring-web</artifactId>  
            <version>${spring.version}</version>  
        </dependency>  
        <dependency>  
            <groupId>org.springframework</groupId>  
            <artifactId>spring-webmvc</artifactId>  
            <version>${spring.version}</version>  
        </dependency>  

        <!-- spring test相关依赖 -->  
        <dependency>  
            <groupId>org.springframework</groupId>  
            <artifactId>spring-test</artifactId>  
            <version>${spring.version}</version>  
        </dependency> 
        <!-- spring依赖  end-->   

        <!-- 5. mybatis依赖  begin-->  
        <dependency>  
            <groupId>org.mybatis</groupId>  
            <artifactId>mybatis</artifactId>  
            <version>${mybatis.version}</version>  
        </dependency>  

        <dependency>  
            <groupId>org.mybatis</groupId>  
            <artifactId>mybatis-spring</artifactId>  
            <version>${mybatis-spring.version}</version>  
        </dependency>  
        <!-- mybatis依赖  end--> 

        <!-- 6. 数据库相关依赖  begin-->  
        <dependency>  
            <groupId>mysql</groupId>  
            <artifactId>mysql-connector-java</artifactId>  
            <version>${mysql.version}</version>  
            <scope>runtime</scope>  
        </dependency>  

        <dependency>  
            <groupId>com.alibaba</groupId>  
            <artifactId>druid</artifactId>  
            <version>${druid.version}</version>  
        </dependency>
        <!-- 数据库相关依赖  end-->   

        <!-- 7. log日志依赖 begin-->  
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>${log4j.version}</version>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>${slf4j.version}</version>
        </dependency>
        <!--log日志依赖 end-->  

        <!-- 10. 其他依赖 begin -->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>${fastjson.version}</version>
        </dependency>

        <!-- fileupload 文件上传 -->
        <dependency>  
            <groupId>commons-fileupload</groupId>  
            <artifactId>commons-fileupload</artifactId>  
            <version>${fileupload.version}</version>  
        </dependency>  

        <!-- POI 相关依赖 -->
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <version>3.10-FINAL</version>
        </dependency>

        <!-- 二维码依赖 -->
        <dependency>
            <groupId>com.google.zxing</groupId>
            <artifactId>core</artifactId>
            <version>3.3.0</version>
        </dependency>

        <!-- gson依赖 -->
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>${gson.version}</version>
        </dependency>

        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
            <version>20160212</version>
        </dependency>

        <!-- 其他依赖 begin -->

    </dependencies>

    <build>
        <finalName>SSM-Demo</finalName>
        <!--  -->
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-deploy-plugin</artifactId>
                <version>2.7</version>
                <configuration>
                    <uniqueVersion>false</uniqueVersion>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-eclipse-plugin</artifactId>
                <version>2.8</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.2</version>
                <configuration>
                    <failOnError>true</failOnError>
                    <verbose>true</verbose>
                    <fork>true</fork>
                    <compilerArgument>-nowarn</compilerArgument>
                    <source>1.7</source>
                    <target>1.7</target>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>2.1.2</version>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>

    </build>

</project>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207
  • 208
  • 209
  • 210
  • 211
  • 212
  • 213
  • 214
  • 215
  • 216
  • 217
  • 218
  • 219
  • 220
  • 221
  • 222
  • 223
  • 224
  • 225
  • 226
  • 227
  • 228
  • 229
  • 230
  • 231
  • 232
  • 233
  • 234
  • 235
  • 236
  • 237
  • 238
  • 239
  • 240
  • 241
  • 242
  • 243
  • 244
  • 245
  • 246
  • 247
  • 248
  • 249
  • 250
  • 251
  • 252
  • 253
  • 254
  • 255
  • 256
  • 257
  • 258
  • 259
  • 260
  • 261
  • 262
  • 263
  • 264
  • 265
  • 266
  • 267
  • 268
  • 269
  • 270
  • 271
  • 272
  • 273

2、SpringMVC国际、文件上传配置
文件上传原文:http://blog.csdn.net/cyh1111/article/details/52960233

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xsi:schemaLocation="   
            http://www.springframework.org/schema/beans   
            http://www.springframework.org/schema/beans/spring-beans-4.1.xsd   
            http://www.springframework.org/schema/context   
            http://www.springframework.org/schema/context/spring-context-4.1.xsd
            http://www.springframework.org/schema/mvc 
            http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd">

    <!-- 处理器映射器  默认的注解映射的支持  方法一 -->
    <mvc:annotation-driven />
    <!-- 注解控测器-->
    <context:component-scan base-package="com.cyh.*">
        <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Service"/>
    </context:component-scan>

    <!-- 国际化资源配置 -->
    <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">  
        <!-- 国际化信息所在的文件名 -->  
        <property name="basename" value="messages/message"/>  
        <!-- 如果在国际化资源文件中找不到对应代码的信息,就用这个代码作为名称  -->                 
        <property name="useCodeAsDefaultMessage" value="true" />  
    </bean> 

    <!-- jsp jstl -->
    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">      
        <property name="prefix" value="/WEB-INF/pages/" />      
        <property name="suffix" value=".jsp" />      
    </bean>        

    <!-- 静态资源过滤 -->
    <mvc:resources location="/res/" mapping="/res/**"/> 
    <mvc:resources location="/WEB-INF/pages/error/" mapping="/WEB-INF/pages/error/**"/> 
    <mvc:resources location="/upload/" mapping="/upload/**"/> 

    <!-- annotation默认的方法映射适配器 -->    
    <bean id="handlerMapping" class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"/>   
    <bean id="handlerAdapter" class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />

    <!-- 支持上传文件 -->  
    <bean id="multipartResolver" class="com.cyh.sy.web.upload.CustomMultipartResolver"/>  
</beans>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45

3、Spring+Mybatis+Druid集成配置

<?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:p="http://www.springframework.org/schema/p"
    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:aop="http://www.springframework.org/schema/aop"
    xmlns:task="http://www.springframework.org/schema/task"
    xsi:schemaLocation="http://www.springframework.org/schema/beans  
                        http://www.springframework.org/schema/beans/spring-beans-4.1.xsd  
                        http://www.springframework.org/schema/context  
                        http://www.springframework.org/schema/context/spring-context-4.1.xsd  
                        http://www.springframework.org/schema/mvc  
                        http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd
                        http://www.springframework.org/schema/tx
                        http://www.springframework.org/schema/tx/spring-tx-4.1.xsd
                        http://www.springframework.org/schema/aop
                        http://www.springframework.org/schema/aop/spring-aop-4.1.xsd
                        http://www.springframework.org/schema/task 
                        http://www.springframework.org/schema/task/spring-task-4.1.xsd">

    <!-- 加载数据库参数 -->
    <context:property-placeholder location="classpath:config.properties"/>  

    <!-- 配置DataSource数据源 -->  
    <!-- 阿里 druid 数据库连接池 -->
    <bean id = "dataSource" class = "com.alibaba.druid.pool.DruidDataSource" destroy-method = "close">  
         <!-- 数据库基本信息配置 -->
         <property name = "url" value = "${druid.url}" />  
         <property name = "username" value = "${druid.username}" />  
         <property name = "password" value = "${druid.password}" />  
         <property name = "driverClassName" value = "${druid.driverClassName}" />  
         <property name = "filters" value = "${druid.filters}" />  

         <!-- 最大并发连接数 -->
         <property name = "maxActive" value = "${druid.maxActive}" />

         <!-- 初始化连接数量 -->
         <property name = "initialSize" value = "${druid.initialSize}" />

         <!-- 配置获取连接等待超时的时间 -->
         <property name = "maxWait" value = "${druid.maxWait}" />

         <!-- 最小空闲连接数 -->
         <property name = "minIdle" value = "${druid.minIdle}" />  

         <!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 -->
         <property name = "timeBetweenEvictionRunsMillis" value ="${druid.timeBetweenEvictionRunsMillis}" />

         <!-- 配置一个连接在池中最小生存的时间,单位是毫秒 -->
         <property name = "minEvictableIdleTimeMillis" value ="${druid.minEvictableIdleTimeMillis}" />  
         <property name = "validationQuery" value = "${druid.validationQuery}" />  
         <property name = "testWhileIdle" value = "${druid.testWhileIdle}" />  
         <property name = "testOnBorrow" value = "${druid.testOnBorrow}" />  
         <property name = "testOnReturn" value = "${druid.testOnReturn}" />  
         <property name = "maxOpenPreparedStatements" value ="${druid.maxOpenPreparedStatements}" />

         <!-- 打开 removeAbandoned 功能 -->
         <property name = "removeAbandoned" value = "${druid.removeAbandoned}" />

         <!-- 1800 秒,也就是 30 分钟 -->
         <property name = "removeAbandonedTimeout" value ="${druid.removeAbandonedTimeout}" />

         <!-- 关闭 abanded 连接时输出错误日志 -->   
         <property name = "logAbandoned" value = "${druid.logAbandoned}" />
    </bean>

    <!-- 配置SqlSessionFactoryBean --> 
    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> 
        <property name="dataSource" ref="dataSource"/>  
        <property name="configLocation" value="classpath:mybatis-config/mybatis-config.xml"/> 
        <!-- mapper和resultmap配置路径   -->
        <property name="mapperLocations" value="classpath:mybatis-config/mapper/*-mapper.xml"></property> 
    </bean>

    <!-- 通过扫描的模式,扫描在com.cyh.sy.dao.mapper目录下的所有mapper -->
    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <property name="basePackage" value="com.cyh.sy.dao"/>  
    </bean>

    <!-- 创建一个sqlSession实例,线程安全的,可以在所有DAO实例共享,原理是将sqlSession,事务与当前线程挂钩 -->
    <bean name="sqlSessionTemplateASS" class="org.mybatis.spring.SqlSessionTemplate" destroy-method="close">
        <constructor-arg index="0" ref="sqlSessionFactory" />
    </bean>

    <!-- 事务相关控制 -->
    <bean name="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="dataSource"/>
    </bean>

    <!-- 通知 -->
    <tx:advice id="tx" transaction-manager="transactionManager">
        <tx:attributes>
            <tx:method name="add*" propagation="REQUIRED" />
            <tx:method name="edit*" propagation="REQUIRED" />
            <tx:method name="remove*" propagation="REQUIRED" />
            <tx:method name="find*" read-only="true" />
            <tx:method name="get*" read-only="true" />
            <tx:method name="select*" read-only="true" />
        </tx:attributes>
    </tx:advice>

    <aop:config>
        <aop:pointcut id="pc" expression="execution(* com.cyh.sy.service.*.*(..))" />
        <!--把事务控制在Service层-->
        <aop:advisor pointcut-ref="pc" advice-ref="tx" />
    </aop:config>

    <!-- 启用注解扫描 -->
    <context:component-scan base-package="com.cyh.*">
        <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
    </context:component-scan>

</beans>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114

4、Mybaits通用CRUD
原文见这里:http://blog.csdn.net/guoshengkai373/article/details/51461242

5、注册邮件激活

/**
 * @描述:邮件发送工具类
 * @作者:cyh
 * @版本:V1.0
 * @创建时间::2016-11-21 下午10:47:36
 */
public class EmailUtils {  

    private static final String FROM = "test@163.com";  

    private static final String PASS_WORD = "test123";  

    /** 
     * 注册成功后,向用户发送帐户激活链接的邮件 
     * @param user 未激活的用户 
     */  
    public static void sendAccountActivateEmail(Company company) {  
        Session session = getSession();  
        Message message = new MimeMessage(session);  
        try {  
            message.setFrom(new InternetAddress(FROM)); 
            message.setSentDate(new Date());  
            message.setSubject("SSM-Demo系统-帐户激活邮件");  
            message.setRecipient(RecipientType.TO, new InternetAddress(company.getCompanyContactsEmail()));  
            message.setContent("<h1>此邮件为:SSM-Demo系统官方激活邮件!请点击下面链接完成激活操作!</h1>" +
                               "<h3><a href='" + GenerateLinkUtils.generateActivateLink(company)+"'>点击激活帐户</a></h3>","text/html;charset=UTF-8");
            message.saveChanges();  
            // 发送邮件  
            Transport.send(message);  
        } catch (Exception e) {  
            e.printStackTrace();  
        }  
    }  

    /** 
     * 发送重设密码链接的邮件 
     */  
    public static void sendResetPasswordEmail(Company company) {  
        Session session = getSession();  
        MimeMessage message = new MimeMessage(session);  
        try {  
            message.setSubject("SSM-Demo系统-找回您的帐户与密码");  
            message.setSentDate(new Date());  
            message.setFrom(new InternetAddress(FROM));  
            message.setRecipient(RecipientType.TO, new InternetAddress(company.getCompanyContactsEmail()));  
            message.setContent("<h1>此邮件为:SSM-Demo系统官方账户与密码找回邮件!请点击下面链接重新设置密码!</h1>" +
                   "<h3><a href='" + GenerateLinkUtils.generateResetPwdLink(company)+"'>点击重新设置密码</a></h3>","text/html;charset=UTF-8");
            message.saveChanges();  
            // 发送邮件  
            Transport.send(message);  
        } catch (Exception e) {  
            e.printStackTrace();  
        }  
    }  


    public static Session getSession() {  
        Properties props = new Properties();  
        props.setProperty("mail.transport.protocol", "smtp");  
        props.setProperty("mail.smtp.host", "smtp.163.com");  
        props.setProperty("mail.smtp.port", "25");  
        props.setProperty("mail.smtp.auth", "true");  
        Session session = Session.getInstance(props, new Authenticator() {  
            @Override  
            protected PasswordAuthentication getPasswordAuthentication() {  
                return new PasswordAuthentication(FROM, PASS_WORD);  
            }  
        });  

        return session;  
    }  
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71

6、页面Datatables实现表格服务端分页、条件查询
http://blog.csdn.net/cyh1111/article/details/52961250

7、toastr消息提醒
使用非常简单,不同消息不同颜色提示!

<!-- 引入toastr js和css文件 -->
<link rel="stylesheet" href="<%=path%>/res/toastr/toastr.min.css">
<script src="<%=path%>/res/toastr/toastr.min.js"></script>

<!-- 设置参数 -->
<script type="text/javascript">
<!--
    toastr.options = {  
        closeButton: false,  
        debug: false,  
        progressBar: true,  
        positionClass: "toast-bottom-center",  
        onclick: null,  
        showDuration: "300",  
        hideDuration: "1000",  
        timeOut: "2000",  
        extendedTimeOut: "1000",  
        showEasing: "swing",  
        hideEasing: "linear",  
        showMethod: "fadeIn",  
        hideMethod: "fadeOut"  
    };  
//-->
</script>

<!-- 使用 -->
toastr.success("操作成功!");
toastr.error("操作失败!");
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28

8、其他功能:文件打包压缩、二维码生成、json序列化、sweetalert消息提醒等等

源代码

数据库脚本:\SSM-Demo\src\main\bin\ssm-demo.sql
CSDN下载:下载
GitHub:下载

个人分类: SpringMVC Mybatis
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值