老师,添加数据后的数据没有在列表显示
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="a" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>新建</title>
<link rel="stylesheet" href="${pageContext.request.contextPath}/css/bootstrap.min.css">
<link rel="stylesheet" href="${pageContext.request.contextPath}/css/add.css">
</head>
<body>
<nav class="navbar navbar-default">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="/dept/list.do">
慕课网科室管理
</a>
</div>
</div>
</nav>
<div class="container">
<div class="jumbotron">
<h1>Hello, XXX!</h1>
<p>请小心的新增科室分类,要是建了一个错误的就不好了。。。</p>
</div>
<div class="page-header">
<h3><small>新建</small></h3>
</div>
<form class="form-horizontal" action="/category/list.do" method="post">
<div class="form-group">
<label for="name" class="name">名称 :</label>
<div class="name">
<input name="name" class="form-control" id="name">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-primary">保存</button>
</div>
</div>
</form>
</div>
<footer class="text-center" >
copy@imooc
</footer>
</body>
</html>
// /category/add.do /category.jsp
public void add(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String name = request.getParameter("name");
Date createTime = null;
Date updateTime = null;
try {
createTime = new SimpleDateFormat("yyyy-MM-dd HH:MM").parse(request.getParameter("createTime"));
updateTime = new SimpleDateFormat("yyyy-MM-dd HH:MM").parse(request.getParameter("updateTime"));
} catch (ParseException e) {
e.printStackTrace();
}
Category category = new Category();
category.setName(name);
category.setCreateTime(createTime);
category.setUpdateTime(updateTime);
categoryService.add(category);
response.sendRedirect("list.do");
}
11
收起
正在回答 回答被采纳积分+1
1回答
4. SSM到Spring Boot入门与综合实战
- 参与学习 人
- 提交作业 323 份
- 解答问题 8263 个
本阶段将带你学习主流框架SSM,以及SpringBoot ,打通成为Java工程师的最后一公里!
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星