SSM框架搭建
-
开发环境
-
项目结构
-
搭建步骤
- 新建maven项目
- Maven配置信息pom.xml
- 在db.properties添加数据库信息
- 在applicationContext.xml中配置Spring
- spring-mvc.xml
- 在log4j.properties中指定日志信息
- UserInfo.java
- UserInfoDao.java
- IUserInfoService.java
- UserInfoServiceImpl.java
- UserInfoMapper.xml
- UserInfoController.java
- web.xml
- index.jsp
- user-list.jsp
开发环境
- IDEA
- mysql5.5
- jdk1.8
- maven
项目结构
搭建步骤
新建maven项目
File–>New–>Project,勾选Create from archetype,选择webapp
输入GroupId和ArtifactId
指定maven的位置
指定项目名称和地址
点击完成后,按照项目结构新建文件和文件夹
Maven配置信息pom.xml
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
| 1<?xml version="1.0" encoding="UTF-8"?>
2<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">
3
4 <modelVersion>4.0.0</modelVersion>
5 <packaging>war</packaging>
6
7 <name>ssm</name>
8 <groupId>com.zhongruan</groupId>
9 <artifactId>ssm</artifactId>
10 <version>1.0-SNAPSHOT</version>
11
12 <properties>
13 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
14 <maven.compiler.source>1.7</maven.compiler.source>
15 <maven.compiler.target>1.7</maven.compiler.target>
16 <!-- spring版本号 -->
17 <spring.version>5.0.2.RELEASE</spring.version>
18 <!-- mybatis版本号 -->
19 <mybatis.version>3.2.6</mybatis.version>
20 <!-- log4j日志文件管理包版本 -->
21 <slf4j.version>1.7.7</slf4j.version>
22 <log4j.version>1.2.17</log4j.version>
23 <c3p0.version>0.9.5.2</c3p0.version>
24 <taglibs.version>1.1.2</taglibs.version>
25 </properties>
26
27 <build>
28 <plugins>
29 <plugin>
30 <groupId>org.mortbay.jetty</groupId>
31 <artifactId>maven-jetty-plugin</artifactId>
32 <version>6.1.7</version>
33 <configuration>
34 <connectors>
35 <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
36 <port>8888</port>
37 <maxIdleTime>30000</maxIdleTime>
38 </connector>
39 </connectors>
40 <webAppSourceDirectory>${project.build.directory}/${pom.artifactId}-${pom.version}</webAppSourceDirectory>
41 <contextPath>/</contextPath>
42 </configuration>
43 </plugin>
44 </plugins>
45 </build>
46
47 <dependencies>
48 <!-- spring核心包 -->
49 <dependency>
50 <groupId>org.springframework</groupId>
51 <artifactId>spring-core</artifactId>
52 <version>${spring.version}</version>
53 </dependency>
54
55 <dependency>
56 <groupId>org.springframework</groupId>
57 <artifactId>spring-web</artifactId>
58 <version>${spring.version}</version>
59 </dependency>
60 <dependency>
61 <groupId>org.springframework</groupId>
62 <artifactId>spring-oxm</artifactId>
63 <version>${spring.version}</version>
64 </dependency>
65 <dependency>
66 <groupId>org.springframework</groupId>
67 <artifactId>spring-tx</artifactId>
68 <version>${spring.version}</version>
69 </dependency>
70
71 <dependency>
72 <groupId>org.springframework</groupId>
73 <artifactId>spring-jdbc</artifactId>
74 <version>${spring.version}</version>
75 </dependency>
76
77 <dependency>
78 <groupId>org.springframework</groupId>
79 <artifactId>spring-webmvc</artifactId>
80 <version>${spring.version}</version>
81 </dependency>
82 <dependency>
83 <groupId>org.springframework</groupId>
84 <artifactId>spring-aop</artifactId>
85 <version>${spring.version}</version>
86 </dependency>
87
88 <dependency>
89 <groupId>org.springframework</groupId>
90 <artifactId>spring-context-support</artifactId>
91 <version>${spring.version}</version>
92 </dependency>
93
94 <dependency>
95 <groupId>org.springframework</groupId>
96 <artifactId>spring-test</artifactId>
97 <version>${spring.version}</version>
98 </dependency>
99 <!-- mybatis核心包 -->
100 <dependency>
101 <groupId>org.mybatis</groupId>
102 <artifactId>mybatis</artifactId>
103 <version>${mybatis.version}</version>
104 </dependency>
105 <!-- mybatis/spring包 -->
106 <dependency>
107 <groupId>org.mybatis</groupId>
108 <artifactId>mybatis-spring</artifactId>
109 <version>1.2.2</version>
110 </dependency>
111 <!-- 导入java ee jar 包 -->
112 <dependency>
113 <groupId>javax</groupId>
114 <artifactId>javaee-api</artifactId>
115 <version>7.0</version>
116 </dependency>
117
118 <!-- 导入Mysql数据库链接jar包 -->
119 <dependency>
120 <groupId>mysql</groupId>
121 <artifactId>mysql-connector-java</artifactId>
122 <version>5.1.30</version>
123 </dependency>
124 <!-- 导入dbcp的jar包,用来在applicationContext.xml中配置数据库 -->
125 <dependency>
126 <groupId>commons-dbcp</groupId>
127 <artifactId>commons-dbcp</artifactId>
128 <version>1.2.2</version>
129 </dependency>
130 <!-- JSTL标签类 -->
131 <dependency>
132 <groupId>jstl</groupId>
133 <artifactId>jstl</artifactId>
134 <version>1.2</version>
135 </dependency>
136 <!-- 日志文件管理包 -->
137 <!-- log start -->
138 <dependency>
139 <groupId>log4j</groupId>
140 <artifactId>log4j</artifactId>
141 <version>${log4j.version}</version>
142 </dependency>
143
144
145 <!-- 数据连接池 -->
146 <dependency>
147 <groupId>com.mchange</groupId>
148 <artifactId>c3p0</artifactId>
149 <version>${c3p0.version}</version>
150 </dependency>
151
152 <dependency>
153 <groupId>taglibs</groupId>
154 <artifactId>standard</artifactId>
155 <version>${taglibs.version}</version>
156 </dependency>
157
158 <dependency>
159 <groupId>org.slf4j</groupId>
160 <artifactId>slf4j-api</artifactId>
161 <version>${slf4j.version}</version>
162 </dependency>
163 <dependency>
164 <groupId>org.slf4j</groupId>
165 <artifactId>slf4j-log4j12</artifactId>
166 <version>${slf4j.version}</version>
167 </dependency>
168
169 <!-- 导入servlet-api/jsp -->
170 <dependency>
171 <groupId>javax.servlet</groupId>
172 <artifactId>javax.servlet-api</artifactId>
173 <version>3.1.0</version>
174 <scope>provided</scope>
175 </dependency>
176 <!-- https://mvnrepository.com/artifact/javax.servlet.jsp/javax.servlet.jsp-api -->
177 <dependency>
178 <groupId>javax.servlet.jsp</groupId>
179 <artifactId>javax.servlet.jsp-api</artifactId>
180 <version>2.3.1</version>
181 <scope>provided</scope>
182 </dependency>
183
184 </dependencies>
185
186</project>
187
188
189 |
在db.properties添加数据库信息
数据库创建信息点击这里
1 2 3 4 5 6
| 1jdbc.driver=com.mysql.jdbc.Driver
2jdbc.url=jdbc:mysql://127.0.0.1:3306/user?useSSL=true&characterEncoding=utf-8
3jdbc.username=root
4jdbc.password=123
5
6 |
在applicationContext.xml中配置Spring
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
| 1<?xml version="1.0" encoding="UTF-8"?>
2<beans xmlns="http://www.springframework.org/schema/beans"
3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4 xmlns:context="http://www.springframework.org/schema/context"
5 xmlns:aop="http://www.springframework.org/schema/aop"
6 xmlns:tx="http://www.springframework.org/schema/tx"
7 xsi:schemaLocation="http://www.springframework.org/schema/beans
8 http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
9 http://www.springframework.org/schema/context
10 http://www.springframework.org/schema/context/spring-context-4.3.xsd
11 http://www.springframework.org/schema/aop
12 http://www.springframework.org/schema/aop/spring-aop-4.3.xsd
13 http://www.springframework.org/schema/tx
14 http://www.springframework.org/schema/tx/spring-tx-4.3.xsd">
15 <!-- 1.配置数据库相关参数properties的属性:${url} -->
16 <context:property-placeholder location="classpath:db.properties"/>
17
18 <!-- 2.配置数据源 -->
19 <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
20 <property name="driverClass" value="${jdbc.driver}"/>
21 <property name="jdbcUrl" value="${jdbc.url}"/>
22 <property name="user" value="${jdbc.username}"/>
23 <property name="password" value="${jdbc.password}"/>
24 <property name="maxPoolSize" value="30"/>
25 <property name="minPoolSize" value="2"/>
26 </bean>
27
28 <!-- 3.配置SqlSessionFactory对象 -->
29 <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
30 <!-- 注入数据库连接池 -->
31 <property name="dataSource" ref="dataSource"/>
32 <!-- 扫描bean包 使用别名 -->
33 <property name="typeAliasesPackage" value="com.zhongruan.bean"></property>
34
35 <!--配置加载映射文件 UserMapper.xml-->
36 <property name="mapperLocations" value="classpath:mapper/*.xml"/>
37
38 </bean>
39
40 <!-- 自动生成dao,mapper-->
41 <!-- 4.配置扫描Dao接口包,动态实现Dao接口,注入到spring容器中 -->
42 <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
43 <!-- 给出需要扫描Dao接口包 -->
44 <property name="basePackage" value="com.zhongruan.dao"/>
45 <!-- 注入sqlSessionFactory -->
46 <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
47 </bean>
48
49
50
51 <!--自动扫描-->
52 <context:component-scan base-package="com.zhongruan"/>
53
54
55 <!-- 配置事务-->
56 <!-- 5.配置事务管理器 -->
57 <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
58 <property name="dataSource" ref="dataSource"/>
59 </bean>
60 <!-- 6.开启事务注解-->
61 <tx:annotation-driven></tx:annotation-driven>
62
63</beans>
64
65 |
spring-mvc.xml
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
| 1<?xml version="1.0" encoding="UTF-8"?>
2<beans xmlns="http://www.springframework.org/schema/beans"
3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4 xmlns:mvc="http://www.springframework.org/schema/mvc"
5 xmlns:context="http://www.springframework.org/schema/context"
6 xmlns:aop="http://www.springframework.org/schema/aop"
7 xmlns:tx="http://www.springframework.org/schema/tx"
8 xsi:schemaLocation="http://www.springframework.org/schema/beans
9 http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
10 http://www.springframework.org/schema/mvc
11 http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd
12 http://www.springframework.org/schema/context
13 http://www.springframework.org/schema/context/spring-context-4.3.xsd
14 http://www.springframework.org/schema/aop
15 http://www.springframework.org/schema/aop/spring-aop-4.3.xsd
16 http://www.springframework.org/schema/tx
17 http://www.springframework.org/schema/tx/spring-tx-4.3.xsd">
18
19 <!-- 1.注解扫描位置-->
20 <context:component-scan base-package="com.zhongruan.controller" />
21
22 <!-- 2.配置映射处理和适配器-->
23 <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping"/>
24 <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter"/>
25
26 <!-- 3.视图的解析器-->
27 <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
28 <property name="prefix" value="/jsp/" />
29 <property name="suffix" value=".jsp" />
30 </bean>
31</beans>
32
33 |
在log4j.properties中指定日志信息
1 2 3 4 5 6 7 8
| 1# Global logging configuration
2log4j.rootLogger=DEBUG, stdout
3# Console output...
4log4j.appender.stdout=org.apache.log4j.ConsoleAppender
5log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
6log4j.appender.stdout.layout.ConversionPattern=%5p [%t] - %m%n
7
8 |
UserInfo.java
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
| 1package com.zhongruan.bean;
2
3public class UserInfo {
4 private int id;
5 private String username;
6 private String password;
7
8 public UserInfo() {
9 }
10
11 @Override
12 public String toString() {
13 return "UserInfo{" +
14 "id=" + id +
15 ", username='" + username + '\'' +
16 ", password='" + password + '\'' +
17 '}';
18 }
19
20 public int getId() {
21 return id;
22 }
23
24 public void setId(int id) {
25 this.id = id;
26 }
27
28 public String getUsername() {
29 return username;
30 }
31
32 public void setUsername(String username) {
33 this.username = username;
34 }
35
36 public String getPassword() {
37 return password;
38 }
39
40 public void setPassword(String password) {
41 this.password = password;
42 }
43}
44
45
46 |
UserInfoDao.java
1 2 3 4 5 6 7 8 9 10 11 12
| 1package com.zhongruan.dao;
2
3import com.zhongruan.bean.UserInfo;
4
5import java.util.List;
6
7public interface IUserInfoDao {
8 public List<UserInfo> findAll();
9}
10
11
12 |
IUserInfoService.java
1 2 3 4 5 6 7 8 9 10 11 12
| 1package com.zhongruan.service;
2
3import com.zhongruan.bean.UserInfo;
4
5import java.util.List;
6
7public interface IUserInfoService {
8 public List<UserInfo> findAll();
9}
10
11
12 |
UserInfoServiceImpl.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| 1package com.zhongruan.service.impl;
2
3import com.zhongruan.bean.UserInfo;
4import com.zhongruan.dao.IUserInfoDao;
5import com.zhongruan.service.IUserInfoService;
6import org.springframework.beans.factory.annotation.Autowired;
7import org.springframework.stereotype.Service;
8
9import java.util.List;
10@Service("userInfoService")
11public class UserInfoServiceImpl implements IUserInfoService {
12 @Autowired
13 IUserInfoDao userInfoDao;
14 @Override
15 public List<UserInfo> findAll() {
16 return userInfoDao.findAll();
17 }
18}
19
20
21 |
UserInfoMapper.xml
1 2 3 4 5 6 7 8 9
| 1<?xml version="1.0" encoding="UTF-8" ?>
2<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
3<mapper namespace="com.zhongruan.dao.IUserInfoDao" >
4 <select id="findAll" resultType="com.zhongruan.bean.UserInfo">
5 select * from userinfo
6 </select>
7</mapper>
8
9 |
UserInfoController.java
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
| 1package com.zhongruan.controller;
2
3import com.zhongruan.bean.UserInfo;
4import com.zhongruan.service.IUserInfoService;
5import org.springframework.beans.factory.annotation.Autowired;
6import org.springframework.stereotype.Controller;
7import org.springframework.web.bind.annotation.RequestMapping;
8import org.springframework.web.servlet.ModelAndView;
9
10import java.util.List;
11
12@Controller
13@RequestMapping("user")
14public class UserInfoController {
15 @Autowired
16 IUserInfoService userInfoService;
17
18 @RequestMapping("findAll.do")
19 public ModelAndView findAll() {
20 List<UserInfo> users = userInfoService.findAll();
21 ModelAndView mv = new ModelAndView();
22 mv.addObject("users", users);
23 mv.setViewName("allUser");
24 return mv;
25 }
26}
27
28
29 |
web.xml
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
| 1<?xml version="1.0" encoding="UTF-8"?>
2<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3 xmlns="http://xmlns.jcp.org/xml/ns/javaee"
4 xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
5 version="3.1">
6
7 <!-- 配置加载类路径的配置文件 -->
8 <context-param>
9 <param-name>contextConfigLocation</param-name>
10 <param-value>classpath*:applicationContext.xml</param-value>
11 </context-param>
12
13 <!-- 配置监听器 -->
14 <listener>
15 <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
16 </listener>
17 <listener>
18 <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
19 </listener>
20
21 <!-- 解决中文乱码过滤器 -->
22 <filter>
23 <filter-name>characterEncodingFilter</filter-name>
24 <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
25 <init-param>
26 <param-name>encoding</param-name>
27 <param-value>UTF-8</param-value>
28 </init-param>
29 </filter>
30 <filter-mapping>
31 <filter-name>characterEncodingFilter</filter-name>
32 <url-pattern>/*</url-pattern>
33 </filter-mapping>
34
35 <!-- 前端控制器(加载classpath:spring-mvc.xml 服务器启动创建servlet) -->
36 <servlet>
37 <servlet-name>dispatcherServlet</servlet-name>
38 <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
39 <!-- 配置初始化参数,创建完DispatcherServlet对象,加载springmvc.xml配置文件 -->
40 <init-param>
41 <param-name>contextConfigLocation</param-name>
42 <param-value>classpath:spring-mvc.xml</param-value>
43 </init-param>
44 <!-- 服务器启动的时候,让DispatcherServlet对象创建 -->
45 <load-on-startup>1</load-on-startup>
46 </servlet>
47 <servlet-mapping>
48 <servlet-name>dispatcherServlet</servlet-name>
49 <url-pattern>*.do</url-pattern>
50 </servlet-mapping>
51
52</web-app>
53
54
55 |
index.jsp
1 2 3 4 5 6 7 8 9 10 11 12 13
| 1<%@ page language="java" contentType="text/html; charset=UTF-8"
2 pageEncoding="UTF-8" isELIgnored="false"%>
3<html>
4<head>
5 <title>Title</title>
6</head>
7<body>
8<h2>hello world</h2>
9<a href="${pageContext.request.contextPath}/user/findAll.do">查询所有用户</a>
10</body>
11</html>
12
13 |
user-list.jsp
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 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337
| 1<%@ page language="java" contentType="text/html; charset=UTF-8"
2 pageEncoding="UTF-8" isELIgnored="false"%>
3<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
4<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
5<html>
6<head>
7<!-- 页面meta -->
8<meta charset="utf-8">
9<meta http-equiv="X-UA-Compatible" content="IE=edge">
10
11<title>数据 - AdminLTE2定制版</title>
12<meta name="description" content="AdminLTE2定制版">
13<meta name="keywords" content="AdminLTE2定制版">
14
15<!-- Tell the browser to be responsive to screen width -->
16<meta
17 content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no"
18 name="viewport">
19
20<link rel="stylesheet"
21 href="${pageContext.request.contextPath}/plugins/bootstrap/css/bootstrap.min.css">
22<link rel="stylesheet"
23 href="${pageContext.request.contextPath}/plugins/font-awesome/css/font-awesome.min.css">
24<link rel="stylesheet"
25 href="${pageContext.request.contextPath}/plugins/ionicons/css/ionicons.min.css">
26<link rel="stylesheet"
27 href="${pageContext.request.contextPath}/plugins/iCheck/square/blue.css">
28<link rel="stylesheet"
29 href="${pageContext.request.contextPath}/plugins/morris/morris.css">
30<link rel="stylesheet"
31 href="${pageContext.request.contextPath}/plugins/jvectormap/jquery-jvectormap-1.2.2.css">
32<link rel="stylesheet"
33 href="${pageContext.request.contextPath}/plugins/datepicker/datepicker3.css">
34<link rel="stylesheet"
35 href="${pageContext.request.contextPath}/plugins/daterangepicker/daterangepicker.css">
36<link rel="stylesheet"
37 href="${pageContext.request.contextPath}/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css">
38<link rel="stylesheet"
39 href="${pageContext.request.contextPath}/plugins/datatables/dataTables.bootstrap.css">
40<link rel="stylesheet"
41 href="${pageContext.request.contextPath}/plugins/treeTable/jquery.treetable.css">
42<link rel="stylesheet"
43 href="${pageContext.request.contextPath}/plugins/treeTable/jquery.treetable.theme.default.css">
44<link rel="stylesheet"
45 href="${pageContext.request.contextPath}/plugins/select2/select2.css">
46<link rel="stylesheet"
47 href="${pageContext.request.contextPath}/plugins/colorpicker/bootstrap-colorpicker.min.css">
48<link rel="stylesheet"
49 href="${pageContext.request.contextPath}/plugins/bootstrap-markdown/css/bootstrap-markdown.min.css">
50<link rel="stylesheet"
51 href="${pageContext.request.contextPath}/plugins/adminLTE/css/AdminLTE.css">
52<link rel="stylesheet"
53 href="${pageContext.request.contextPath}/plugins/adminLTE/css/skins/_all-skins.min.css">
54<link rel="stylesheet"
55 href="${pageContext.request.contextPath}/css/style.css">
56<link rel="stylesheet"
57 href="${pageContext.request.contextPath}/plugins/ionslider/ion.rangeSlider.css">
58<link rel="stylesheet"
59 href="${pageContext.request.contextPath}/plugins/ionslider/ion.rangeSlider.skinNice.css">
60<link rel="stylesheet"
61 href="${pageContext.request.contextPath}/plugins/bootstrap-slider/slider.css">
62</head>
63
64<body class="hold-transition skin-blue sidebar-mini">
65
66 <div class="wrapper">
67
68 <!-- 页面头部 -->
69 <jsp:include page="header.jsp"></jsp:include>
70 <!-- 页面头部 /-->
71
72 <!-- 导航侧栏 -->
73 <jsp:include page="aside.jsp"></jsp:include>
74 <!-- 导航侧栏 /-->
75
76 <!-- 内容区域 -->
77 <div class="content-wrapper">
78
79 <!-- 内容头部 -->
80 <section class="content-header">
81 <h1>
82 用户管理 <small>全部用户</small>
83 </h1>
84 <ol class="breadcrumb">
85 <li><a href="${pageContext.request.contextPath}/index.jsp"><i
86 class="fa fa-dashboard"></i> 首页</a></li>
87 <li><a
88 href="${pageContext.request.contextPath}/user/findAll.do">用户管理</a></li>
89
90 <li class="active">全部用户</li>
91 </ol>
92 </section>
93 <!-- 内容头部 /-->
94
95 <!-- 正文区域 -->
96 <section class="content"> <!-- .box-body -->
97 <div class="box box-primary">
98 <div class="box-header with-border">
99 <h3 class="box-title">列表</h3>
100 </div>
101
102 <div class="box-body">
103
104 <!-- 数据表格 -->
105 <div class="table-box">
106
107 <!--工具栏-->
108 <div class="pull-left">
109 <div class="form-group form-inline">
110 <div class="btn-group">
111 <button type="button" class="btn btn-default" title="新建" onclick="#">
112 <i class="fa fa-file-o"></i> 新建
113 </button>
114
115 <button type="button" class="btn btn-default" title="刷新">
116 <i class="fa fa-refresh"></i> 刷新
117 </button>
118 </div>
119 </div>
120 </div>
121 <div class="box-tools pull-right">
122 <div class="has-feedback">
123 <input type="text" class="form-control input-sm"
124 placeholder="搜索"> <span
125 class="glyphicon glyphicon-search form-control-feedback"></span>
126 </div>
127 </div>
128 <!--工具栏/-->
129
130 <!--数据列表-->
131 <table id="dataList"
132 class="table table-bordered table-striped table-hover dataTable">
133 <thead>
134 <tr>
135 <th class=""style="padding-right: 0px"><input
136 id="selall" type="checkbox" class="icheckbox_square-blue">
137 </th>
138 <th class="sorting_asc">ID</th>
139 <th class="sorting_desc">用户名</th>
140 <th class="sorting_asc sorting_asc_disabled">密码</th>
141 <th class="text-center">操作</th>
142 </tr>
143 </thead>
144 <tbody>
145
146 <c:forEach items="${userList}" var="user">
147 <tr>
148 <td><input name="ids" type="checkbox"></td>
149 <td>${user.id }</td>
150 <td>${user.username }</td>
151 <td>${user.password }</td>
152 <td class="text-center">
153 <a href="${pageContext.request.contextPath}/user/findById.do?id=${user.id}" class="btn bg-olive btn-xs">详情</a>
154 <a href="${pageContext.request.contextPath}/user/findUserByIdAndAllRole.do?id=${user.id}" class="btn bg-olive btn-xs">添加角色</a>
155 </td>
156 </tr>
157 </c:forEach>
158 </tbody>
159 <!--
160 <tfoot>
161 <tr>
162 <th>Rendering engine</th>
163 <th>Browser</th>
164 <th>Platform(s)</th>
165 <th>Engine version</th>
166 <th>CSS grade</th>
167 </tr>
168 </tfoot>-->
169 </table>
170 <!--数据列表/-->
171
172 </div>
173 <!-- 数据表格 /-->
174
175 </div>
176 <!-- /.box-body -->
177
178 <!-- .box-footer-->
179 <div class="box-footer">
180 <div class="pull-left">
181 <div class="form-group form-inline">
182 总共2 页,共14 条数据。 每页 <select class="form-control">
183 <option>1</option>
184 <option>2</option>
185 <option>3</option>
186 <option>4</option>
187 <option>5</option>
188 </select> 条
189 </div>
190 </div>
191
192 <div class="box-tools pull-right">
193 <ul class="pagination">
194 <li><a href="#" aria-label="Previous">首页</a></li>
195 <li><a href="#">上一页</a></li>
196 <li><a href="#">1</a></li>
197 <li><a href="#">2</a></li>
198 <li><a href="#">3</a></li>
199 <li><a href="#">4</a></li>
200 <li><a href="#">5</a></li>
201 <li><a href="#">下一页</a></li>
202 <li><a href="#" aria-label="Next">尾页</a></li>
203 </ul>
204 </div>
205
206 </div>
207 <!-- /.box-footer-->
208
209 </div>
210
211 </section>
212 <!-- 正文区域 /-->
213
214 </div>
215 <!-- @@close -->
216 <!-- 内容区域 /-->
217
218 <!-- 底部导航 -->
219 <footer class="main-footer">
220 <div class="pull-right hidden-xs">
221 <b>Version</b> 1.0.8
222 </div>
223 <strong>Copyright © 2014-2017 <a
224 href="http://www.itcast.cn">研究院研发部</a>.
225 </strong> All rights reserved. </footer>
226 <!-- 底部导航 /-->
227
228 </div>
229
230 <script src="../plugins/jQuery/jquery-2.2.3.min.js"></script>
231 <script src="../plugins/jQueryUI/jquery-ui.min.js"></script>
232 <script>
233 $.widget.bridge('uibutton', $.ui.button);
234 </script>
235 <script src="../plugins/bootstrap/js/bootstrap.min.js"></script>
236 <script src="../plugins/raphael/raphael-min.js"></script>
237 <script src="../plugins/morris/morris.min.js"></script>
238 <script src="../plugins/sparkline/jquery.sparkline.min.js"></script>
239 <script src="../plugins/jvectormap/jquery-jvectormap-1.2.2.min.js"></script>
240 <script src="../plugins/jvectormap/jquery-jvectormap-world-mill-en.js"></script>
241 <script src="../plugins/knob/jquery.knob.js"></script>
242 <script src="../plugins/daterangepicker/moment.min.js"></script>
243 <script src="../plugins/daterangepicker/daterangepicker.js"></script>
244 <script src="../plugins/daterangepicker/daterangepicker.zh-CN.js"></script>
245 <script src="../plugins/datepicker/bootstrap-datepicker.js"></script>
246 <script
247 src="../plugins/datepicker/locales/bootstrap-datepicker.zh-CN.js"></script>
248 <script
249 src="../plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.min.js"></script>
250 <script src="../plugins/slimScroll/jquery.slimscroll.min.js"></script>
251 <script src="../plugins/fastclick/fastclick.js"></script>
252 <script src="../plugins/iCheck/icheck.min.js"></script>
253 <script src="../plugins/adminLTE/js/app.min.js"></script>
254 <script src="../plugins/treeTable/jquery.treetable.js"></script>
255 <script src="../plugins/select2/select2.full.min.js"></script>
256 <script src="../plugins/colorpicker/bootstrap-colorpicker.min.js"></script>
257 <script
258 src="../plugins/bootstrap-wysihtml5/bootstrap-wysihtml5.zh-CN.js"></script>
259 <script src="../plugins/bootstrap-markdown/js/bootstrap-markdown.js"></script>
260 <script
261 src="../plugins/bootstrap-markdown/locale/bootstrap-markdown.zh.js"></script>
262 <script src="../plugins/bootstrap-markdown/js/markdown.js"></script>
263 <script src="../plugins/bootstrap-markdown/js/to-markdown.js"></script>
264 <script src="../plugins/ckeditor/ckeditor.js"></script>
265 <script src="../plugins/input-mask/jquery.inputmask.js"></script>
266 <script
267 src="../plugins/input-mask/jquery.inputmask.date.extensions.js"></script>
268 <script src="../plugins/input-mask/jquery.inputmask.extensions.js"></script>
269 <script src="../plugins/datatables/jquery.dataTables.min.js"></script>
270 <script src="../plugins/datatables/dataTables.bootstrap.min.js"></script>
271 <script src="../plugins/chartjs/Chart.min.js"></script>
272 <script src="../plugins/flot/jquery.flot.min.js"></script>
273 <script src="../plugins/flot/jquery.flot.resize.min.js"></script>
274 <script src="../plugins/flot/jquery.flot.pie.min.js"></script>
275 <script src="../plugins/flot/jquery.flot.categories.min.js"></script>
276 <script src="../plugins/ionslider/ion.rangeSlider.min.js"></script>
277 <script src="../plugins/bootstrap-slider/bootstrap-slider.js"></script>
278 <script>
279 $(document).ready(function() {
280 // 选择框
281 $(".select2").select2();
282
283 // WYSIHTML5编辑器
284 $(".textarea").wysihtml5({
285 locale : 'zh-CN'
286 });
287 });
288
289 // 设置激活菜单
290 function setSidebarActive(tagUri) {
291 var liObj = $("#" + tagUri);
292 if (liObj.length > 0) {
293 liObj.parent().parent().addClass("active");
294 liObj.addClass("active");
295 }
296 }
297
298 $(document)
299 .ready(
300 function() {
301
302 // 激活导航位置
303 setSidebarActive("admin-datalist");
304
305 // 列表按钮
306 $("#dataList td input[type='checkbox']")
307 .iCheck(
308 {
309 checkboxClass : 'icheckbox_square-blue',
310 increaseArea : '20%'
311 });
312 // 全选操作
313 $("#selall")
314 .click(
315 function() {
316 var clicks = $(this).is(
317 ':checked');
318 if (!clicks) {
319 $(
320 "#dataList td input[type='checkbox']")
321 .iCheck(
322 "uncheck");
323 } else {
324 $(
325 "#dataList td input[type='checkbox']")
326 .iCheck("check");
327 }
328 $(this).data("clicks",
329 !clicks);
330 });
331 });
332 </script>
333</body>
334
335</html>
336
337 |