创建模型
CREATE TABLE t_role (
`id` INT (11) NOT NULL auto_increment,
`name` VARCHAR (255),
PRIMARY KEY (id)
);
逆向工程
1、修改/atcrowdfunding-reverse/src/main/resources/generatorConfig.xml
<table tableName="t_role" domainObjectName="Role" />
选择pom.xml----》 Run as —》 Maven build … —》将Goal的值设置为:mybatis-generator:generate----》Run
2、调整Role.java:生成无参构造器、有参构造器和toString方法
3、逆向工程生成的资源各归各位
-
将atcrowdfunding-reverse/src/main/java目录下的com.atguigu.crowd.funding.entity包调整到atcrowdfunding-admin-4-entity模块的/src/main/java下
-
atcrowdfunding-reverse/src/main/java目录下的com.atguigu.crowd.funding.mapper包放到component模块的/src/main/java下
-
在atcrowdfunding-admin-1-webui/src/main/resources/mybatis/mapper目录,然后将com.atguigu.crowd.funding.mapper包的AdminMapper.xml放在atcrowdfunding-admin-1-webui模块的/src/main/resources下
创建组件
前往角色维护页面
在/atcrowdfunding-admin-1-webui/src/main/webapp/WEB-INF/include-sidebar.jsp修改角色维护超链接
<li style="height:30px;">
<a href="role/to/page.html"><i class="glyphicon glyphicon-king"></i> 角色维护</a>
</li>
在spring-web-mvc.xml文件中配置view-controller
<mvc:view-controller path="/role/to/page.html" view-name="role-page"/>
创建/atcrowdfunding-admin-1-webui/src/main/webapp/WEB-INF/role-page.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="UTF-8">
<%@ include file="/WEB-INF/include-head.jsp"%>
<body>
<%@ include file="/WEB-INF/include-nav.jsp"%>
<div class="container-fluid">
<div class="row">
<%@ include file="/WEB-INF/include-sidebar.jsp"%>
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
<i class="glyphicon glyphicon-th"></i> 数据列表
</h3>
</div>
<div class="panel-body">
<form class="form-inline" role="form" style="float: left;">
<div class="form-group has-feedback">
<div class="input-group">
<div class="input-group-addon">查询条件</div>
<input class="form-control has-success" type="text"
placeholder="请输入查询条件">
</div>
</div>
<button type="button" class="btn btn-warning">
<i class="glyphicon glyphicon-search"></i> 查询
</button>
</form>
<button type="button" class="btn btn-danger"
style="float: right; margin-left: 10px;">
<i class=" glyphicon glyphicon-remove"></i> 删除
</button>
<button type="button" class="btn btn-primary"
style="float: right;" onclick="window.location.href='form.html'">
<i class="glyphicon glyphicon-plus"></i> 新增
</button>
<br>
<hr style="clear: both;">
<div class="table-responsive">
<table class="table table-bordered">
<thead>
<tr>
<th width="30">#</th>
<th width="30"><input type="checkbox"></th>
<th>名称</th>
<th width="100">操作</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td><input type="checkbox"></td>
<td>PM - 项目经理</td>
<td>
<button type="button" class="btn btn-success btn-xs">
<i class=" glyphicon glyphicon-check"></i>
</button>
<button type="button" class="btn btn-primary btn-xs">
<i class=" glyphicon glyphicon-pencil"></i>
</button>
<button type="button" class="btn btn-danger btn-xs">
<i class=" glyphicon glyphicon-remove"></i>
</button>
</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="6" align="center">
<ul class="pagination">
<li class="disabled"><a href="#">上一页</a></li>
<li class="active"><a href="#">1 <span
class="sr-only">(current)</span></a></li>
<li><a href="#">2</a></li>
<li><a href="#">3</a></li>
<li><a href="#">4</a></li>
<li><a href="#">5</a></li>
<li><a href="#">下一页</a></li>
</ul>
</td>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>