JavaWeb JavaBean JSP MVC MySQL Tomcat JavaScript Bootstrap Ajax
基础JSP+Servlet或JSP+SSM(Spring、SpringMVC、MyBatis)框架或JSP+SSM+Maven(pom.xml)框架或SpringBoot…均可
开发工具:eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">毕业生离校管理系统</span> <span class="icon-bar"></span>
<span class="icon-bar"></span> <span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">毕业生离校管理系统</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li><a href="#">欢迎:<span style="color: yellow">${loginUser.username}</span></a></li>
<li><a href="AuthServlet?action=logout">退出</a></li>
</ul>
</div>
</div>
</nav>
<div class="container-fluid">
<div class="row">
<div class="col-sm-3 col-md-2 sidebar">
<!-- 侧边栏 -->
<jsp:include page="menu.jsp">
vo.setStudentText(Util.decode(request, "studentText"));
StudentService studentService = new StudentServiceImpl();
//调用Service层更新方法(update),更新记录
studentService.update(vo);
this.redirectList(request, response);
} else if ("get".equalsIgnoreCase(action) || "editPre".equalsIgnoreCase(action)) {//根据主键ID,查询详情信息并跳转到详情页面或编辑页面
Serializable id = Util.decode(request, "id");//取出页面传入的主键,用于查询详情
StudentService studentService = new StudentServiceImpl();
Student vo = studentService.get(id);
response.getWriter().println(com.alibaba.fastjson.JSONObject.toJSONString(vo));
} else {//默认去列表页面
this.redirectList(request, response);
<br>
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
<div class="row">
<div class="col-sm-7">
<div class="input-group">
<input class="form-control" type="hidden" id="searchColumn" name="searchColumn" value="notice_name"/>
<input class="form-control" type="text" id="search_keyword" name="search_keyword" placeholder="标题"/> <span class="input-group-btn"><button class="btn btn-pill btn-line btn-warning" type="button" onclick="searchList()">搜索</button></span>
</div>
</div>
<div class="col-sm-5">
<button type="button" <c:if test="${loginUser.userType != '管理员'}">disabled="disabled" title="没有权限!!!"</c:if> class="btn btn-pill btn-line btn-default" data-toggle="modal" data-target="#modal-add">添加公告
</button>
</div>
</div>
<br>
<br>
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title">更新学生信息</h4>
</div>
<div class="modal-body">
<div class="form-group hidden">
<label class="control-label">(hidden)</label>
<input type="text" class="form-control" name="action" value="edit">
<input type="text" readonly class="form-control" name="id" id="edit-id">
</div>
<div class="form-group">
<label for="edit-studentName" class="control-label">姓名:</label>
<input type="text" class="form-control" name="studentName" id="edit-studentName">
</div>
<div class="form-group">
<label for="edit-studentAge" class="control-label">年龄:</label>
<input type="text" class="form-control" name="studentAge" id="edit-studentAge">
</div>
<div class="form-group">
<label class="control-label">性别:</label>
<input name="studentSex" id="edit-studentSex_男" type="radio" value="男"/>男
<input name="studentSex" id="edit-studentSex_女" type="radio" value="女"/>女
</div>
<!-- info -->
<div class="modal fade" id="modal-info" tabindex="-1" role="dialog"
aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<form>
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title">公告</h4>
<label for="edit-createTime" class="control-label">创建时间:</label>
<input type="text" class="form-control" name="createTime" id="edit-createTime">
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-pill btn-line btn-default" data-dismiss="modal">取消</button>
<button type="submit" class="btn btn-pill btn-line btn-default">提交</button>
</div>
</form>
</div>
</div>
</div>
<!-- delete -->
<div class="modal fade" id="modal-delete" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<form action="NoticeServlet">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title">删除公告</h4>
</div>
<input type="text" class="form-control" name="studentDate" id="edit-studentDate">
</div>
<div class="form-group">
<label for="edit-studentText" class="control-label">备注:</label>
<textarea style="height: 100px;" class="form-control" name="studentText" id="edit-studentText"></textarea>
</div>
<div class="form-group hidden">
<label for="edit-createTime" class="control-label">创建时间:</label>
<input type="text" class="form-control" name="createTime" id="edit-createTime">
</div>
</div>
<div class="modal-footer">
}
if (isMessyCode(str)) {
str = new String(str.getBytes("GBK"), "GB2312");
}
if (isMessyCode(str)) {
str = new String(str.getBytes("UTF-8"), "GBK");
}
if (isMessyCode(str)) {
str = new String(str.getBytes("ISO-8859-1"), "GBK");
}
if (isMessyCode(str)) {
str = new String(str.getBytes("GB2312"), "GBK");
}
} catch (Exception e) {
e.printStackTrace();
}
System.out.println(parameterName + "==" + str.trim());
NoticeService noticeService = new NoticeServiceImpl();
//调用Service层删除方法(delete),将对应的记录删除
noticeService.delete(id);
this.redirectList(request, response);
} else if ("edit".equals(action)) {//修改
//取出页面传进来的各个数据,并设置到Notice对象的属性里
Notice vo = new Notice();
vo.setId(Long.valueOf(Util.decode(request, "id")));
vo.setNoticeName(Util.decode(request, "noticeName"));
vo.setNoticeText(Util.decode(request, "noticeText"));
vo.setNoticeType(Util.decode(request, "noticeType"));
vo.setCreateDate(Util.decode(request, "createDate"));
<div class="modal-footer">
<button type="button" class="btn btn-pill btn-line btn-default" data-dismiss="modal">关闭</button>
</div>
</form>
</div>
</div>
</div>
<!-- edit -->
<div class="modal fade" id="modal-edit" tabindex="-1" role="dialog"
aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<form action="NoticeServlet" onsubmit="return editCheck()">
</nav>
<div class="container-fluid">
<div class="row">
<div class="col-sm-3 col-md-2 sidebar">
<!-- 侧边栏 -->
<jsp:include page="menu.jsp">
<jsp:param value="active" name="Notice_active"/>
</jsp:include>
</div>
<br>
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
<div class="row">
<div class="col-sm-7">
<div class="input-group">
params.put("keyword", username);
params.put("startIndex", 0);
params.put("pageSize", Long.MAX_VALUE);
List<User> list = (List<User>) userService.list(params).get("list");
for (User user : list) {
if (user.getUsername().equals(username) /*&& user.getPassword().equals(password)*/) {//说明该用户名已存在,必须换个用户名才能注册
request.getSession().setAttribute("alert_msg", "错误:用户名已存在!");
request.getRequestDispatcher("register.jsp").forward(request, response);
return;
}
}
User vo = new User();
vo.setUsername(username);
vo.setPassword(password);
//vo.setUserType("普通用户");//需要设置一个默认值
userService.add(vo);
request.getSession().setAttribute("alert_msg", "注册成功!用户名:[" + username + "]");
request.getRequestDispatcher("login.jsp").forward(request, response);
} else if ("logout".equalsIgnoreCase(action)) {//登出
HttpSession session = request.getSession();
User user = (User) session.getAttribute("loginUser");
if (user != null) {
</div>
<div class="form-group">
<label for="edit-createDate" class="control-label">创建时间:</label>
<input type="text" class="form-control" name="createDate" id="edit-createDate">
</div>
<div class="form-group hidden">
<label for="edit-createTime" class="control-label">创建时间:</label>
<input type="text" class="form-control" name="createTime" id="edit-createTime">
</div>
</div>
<div class="form-group hidden">
<label class="control-label">(hidden)</label>
<input type="hidden" class="form-control" name="action" value="delete">
<input type="text" class="form-control" name="id" id="delete-id">
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-pill btn-line btn-default" data-dismiss="modal">取消</button>
<button type="submit" class="btn btn-pill btn-line btn-danger">删除</button>
</div>
</form>
</div>
</div>
</div>
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public int getTotalPage() {
return totalPage;
}
public void setTotalPage(int totalPage) {
this.totalPage = totalPage;
</div>
<div class="form-group">
<label for="add-studentPhone" class="control-label">联系方式:</label>
<input type="text" class="form-control" name="studentPhone" id="add-studentPhone">
</div>
<div class="form-group">
<label class="control-label">离校审核:</label>
<input name="studentStatus" id="add-studentStatus_已通过" type="radio" value="已通过" checked="checked"/>已通过
<input name="studentStatus" id="add-studentStatus_待审核" type="radio" value="待审核"/>待审核
</div>
<div class="form-group">
<label for="add-studentDate" class="control-label">离校日期:</label>
<input type="text" class="form-control" name="studentDate" id="add-studentDate">
</div>
<div class="form-group">
<label for="add-studentText" class="control-label">备注:</label>
private String searchColumn;//待模糊查询的列
private String keyword;//待模糊查询的关键字
//通过pageNum,pageSize,totalRecord计算得来tatalPage和startIndex,构造方法中将pageNum,pageSize,totalRecord获得
public PageBean(int pageNum, int totalRecord) {
this.pageNum = (pageNum = Math.max(pageNum, 1));
this.pageSize = 10;//默认为10
this.totalRecord = totalRecord;
//totalPage 总页数
if (totalRecord % pageSize == 0) {
//说明整除,正好每页显示pageSize条数据,没有多余一页要显示少于pageSize条数据的
this.totalPage = totalRecord / pageSize;
} else {
//不整除,就要在加一页,来显示多余的数据。
this.totalPage = totalRecord / pageSize + 1;
}
//开始索引
this.startIndex = (pageNum - 1) * pageSize;
//显示5页,这里自己可以设置,想显示几页就自己通过下面算法修改
this.start = 1;
</div>
<div class="form-group">
<label for="add-noticeText" class="control-label">内容:</label>
<textarea style="height: 100px;" class="form-control" name="noticeText" id="add-noticeText"></textarea>
</div>
<div class="form-group">
<label for="add-noticeType" class="control-label">类型:</label>
<input type="text" class="form-control" name="noticeType" id="add-noticeType">
</div>
<div class="form-group">
<label for="add-createDate" class="control-label">创建时间:</label>
return totalPage;
}
public void setTotalPage(int totalPage) {
this.totalPage = totalPage;
}
public int getStartIndex() {
return startIndex;
}
public void setStartIndex(int startIndex) {
this.startIndex = startIndex;
}
public int getStart() {
return start;
}
private Long id;//主键
private String studentName;//姓名
private String studentAge;//年龄
private String studentSex;//性别:男/女
private String studentNumber;//学号
private String studentClass;//班级
private String studentPhone;//联系方式
private String studentStatus;//离校审核:已通过/待审核
private String studentDate;//离校日期
private String studentText;//备注
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getStudentName() {
<c:forEach items="${list}" var="vo">
<tr>
<td>${vo.username}</td>
<td>${vo.realName}</td>
<td>${vo.userSex}</td>
<td>${vo.userPhone}</td>
<td title="${vo.userText}">
<c:choose>
<c:when test="${fn:length(vo.userText) > 19}">
<c:out value="${fn:substring(vo.userText, 0, 19)}..."/>
</c:when>
<c:otherwise>
e.printStackTrace();
}
return vo;
}
//@Override
public Map<String, Object> list(Map<String, Object> params) {
List<Notice> list = new ArrayList();
int totalCount = 0;
String condition = "";
String sqlList;
if (params.get("searchColumn") != null && !"".equals(params.get("searchColumn"))) {
condition += " and `" + params.get("searchColumn") + "` like '%" + params.get("keyword") + "%'";
}
try {
Connection c = Util.getConnection();
PreparedStatement ps;
ResultSet rs;
String limit = (params.get("startIndex") != null && params.get("pageSize") != null) ? " limit " + params.get("startIndex") + "," + params.get("pageSize") : "";
sqlList = "select * from `t_notice` where 1=1 " + condition + " order by id asc " + limit + ";";
ps = c.prepareStatement(sqlList);
//@Override
public void add(Student vo) {
String sql = "insert into `t_student` (`student_name`,`student_age`,`student_sex`,`student_number`,`student_class`,`student_phone`,`student_status`,`student_date`,`student_text`) values(?,?,?,?,?,?,?,?,?)";
try {
Connection c = Util.getConnection();
PreparedStatement ps = c.prepareStatement(sql);
ps.setString(1, vo.getStudentName());
ps.setString(2, vo.getStudentAge());
ps.setString(3, vo.getStudentSex());
<input type="text" class="form-control" name="userPhone" id="edit-userPhone">
</div>
<div class="form-group">
<label for="edit-userText" class="control-label">备注:</label>
<textarea style="height: 100px;" class="form-control" name="userText" id="edit-userText"></textarea>
</div>
<div class="form-group">
<label class="control-label">类型:</label>
<input <c:if test="${loginUser.userType != '管理员'}">disabled="disabled" title="没有权限!!!"</c:if> name="userType" id="edit-userType_管理员" type="radio" value="管理员"/>管理员
<input name="userType" id="edit-userType_普通用户" type="radio" value="普通用户"/>普通用户
</div>
<div class="form-group hidden">
<label for="edit-createTime" class="control-label">创建时间:</label>
<input type="text" class="form-control" name="createTime" id="edit-createTime">
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-pill btn-line btn-default" data-dismiss="modal">取消</button>
<button type="submit" class="btn btn-pill btn-line btn-default">提交</button>
</div>
</form>
</div>
/**
* 处理Post请求
*
* @param request
* @param response
* @throws ServletException
* @throws IOException
*/
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//过滤编码
request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");
String action = Util.decode(request, "action");
if ("add".equals(action)) {//增加
User vo = new User();
//取出页面传进来的各个数据,并设置到User对象的属性里
vo.setUsername(Util.decode(request, "username"));
vo.setPassword(Util.decode(request, "password"));
<input type="text" class="form-control" id="username" name="username" placeholder="请输入您的账号" >
</div>
</div>
<div class="form-group">
<label for="password" class="col-sm-3 control-label">密码</label>
<div class="col-sm-7">
<input type="password" class="form-control" id="password" name="password" placeholder="请输入您的密码" >
</div>
</div>
<div class="form-group">
<label for="password" class="col-sm-3 control-label">验证码</label>
<div class="col-sm-7 form-inline">
<input type="text" id="validationCode" name="validationCode"
style="width: 81px;height: 34px;padding: 6px 12px;font-size: 14px;border-radius: 4px;color: black;"
placeholder="验证码">
<img id="img_validation_code" src="AuthServlet?action=validationCode" onclick="refresh()" style="height: 30px;width: 135px;"/>
</div>
</div>
<div class="loginBtn">
<button type="submit" class=" btn btn-pill btn-line btn-success loginBtn">登录</button>
public class PageBean<T> {
private List<T> list;//根据条件查询出来的list集合
private int totalRecord;//根据条件查询出来的数量
public List<T> getList() {
return list;
}
public void setList(List<T> list) {
this.list = list;
}
public int getTotalRecord() {
return totalRecord;
}
public void setTotalRecord(int totalRecord) {
this.totalRecord = totalRecord;
}
//--分页逻辑
//已知数据
private int pageNum;//当前页,从请求那边传过来。
private int pageSize;//每页显示的数据条数。
运行环境
Java≥6、Tomcat≥7.0、MySQL≥5.5
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
技术框架
JavaWeb JavaBean JSP MVC MySQL Tomcat JavaScript Bootstrap Ajax
基础JSP+Servlet或JSP+SSM(Spring、SpringMVC、MyBatis)框架或JSP+SSM+Maven(pom.xml)框架或SpringBoot…均可
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
登录、注册、退出、用户模块、公告模块、学生信息模块的增删改查管理
↖[获取源码方式]见左侧