手把手搭建一个SSM后台权限管理系统项目(适合有基础新手)
是将基础管理系统公有的一些基本功能抽离出来,做成一个单独的可用系统,以后直接在上面添加功能即可变成相应的系统。
开发环境要求
开发工具:Eclipse(MyEclipse、idea、sts)
我这里用的是Eclipse(你们应该也是用的这个,是吧?)
Java版本:JDK 1.8服务器:tomcat 7.0
数据库:MySQL 5.7 数据库编译工具navicat
系统采用技术: spring+springMVC+mybaits+EasyUI+jQuery+Ajax+面向接口编程
系统实现的功能
菜单管理、角色管理、用户管理、日志管理,不同的角色分配相应的权限,用户分配不同的角色登录后显示相应被分配的功能
项目结构:
1. 在WebRoot/WEB-INF/lib下导入必须的jar包
2.db.properties数据库连接配置文件
datasource.connection.driver_class=com.mysql.jdbc.Driver
datasource.connection.url=jdbc:mysql://localhost:3306/db_base_project?useUnicode=true&characterEncoding=utf-8
datasource.connection.username=root
datasource.connection.password=
#连接池保持的最小连接数,default : 3(建议使用)
datasource.connection.minPoolSize=3
#连接池中拥有的最大连接数,如果获得新连接时会使连接总数超过这个值则不会再获取新连接,而是等待其他连接释放,所以这个值有可能会设计地很大,default : 15(建议使用)
datasource.connection.maxPoolSize=15
这里只是部分连接配置文件
3.spring-mvc.xml配置文件
<?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:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd
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/aop http://www.springframework.org/schema/aop/spring-aop-4.2.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.2.xsd">
<!-- 只需要扫描包中的 Controller 注解 -->
<context:component-scan base-package="com.ischoolbar.programmer.controller">
<context:include-filter type="annotation"
expression="org.springframework.stereotype.Controller" />
</context:component-scan>
<!-- 启动 mvc 注解驱动 -->
<mvc:annotation-driven></mvc:annotation-driven>
<!-- 启动定时任务 -->
<task:annotation-driven/>
<!-- 静态资源处理 -->
<mvc:default-servlet-handler/>
<!-- 配置视图解析器 -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views/"></property>
<property name="suffix" value=".jsp"></property>
</bean>
<!-- 文件上传 -->
<bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<!-- 上传文件大小限制 -->
<property name="maxUploadSize">
<value>10485760</value>
</property>
<!-- 请求的编码格式, 和 jsp 页面一致 -->
<property name="defaultEncoding">
<value>UTF-8</value>
</property>
</bean>
<!-- 后台访问拦截器 -->
<!-- -->
<mvc:interceptors>
<mvc:interceptor>
<mvc:mapping path="/admin/**"/>
<mvc:mapping path="/system/*"/>
<mvc:exclude-mapping path="/system/login"/>
<mvc:exclude-mapping path="/system/get_cpacha"/>
<mvc:exclude-mapping path="/resources/**"/>
<bean class="com.ischoolbar.programmer.interceptor.admin.LoginInterceptor"></bean>
</mvc:interceptor>
</mvc:interceptors>
</beans>
4.applicationContext.xml配置文件
<?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:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
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.springframe