前台没有获得时间后面的小时分秒,只有日期
# 具体遇到的问题
前台没有获得时间后面的小时分秒,只有日期
# 报错信息的截图
# 相关课程内容截图
# 尝试过的解决思路和结果
# 粘贴全部相关代码,切记添加代码注释(请勿截图)
在这里输入代码,可通过选择【代码语言】突出显示
<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>
<head>
<meta charset="UTF-8">
<title>留言板</title>
<link rel="stylesheet"
href="${pageContext.request.contextPath}/css/index.css">
<script type="text/javascript">
</script>
</head>
<body>
<header>
<div class="container">
<%
if (request.getSession().getAttribute("existUser") != null) {
%>
<nav>
<a href="${pageContext.request.contextPath}/my_message_list.jsp">我的留言</a>
</nav>
<nav>
<a
href="${pageContext.request.contextPath }/UserServlet?method=edit">我的信息</a>
</nav>
<%
} else {
%>
<nav>
<a href="${pageContext.request.contextPath}/login.jsp">登录</a> <a
href="${pageContext.request.contextPath}/reg.jsp">注册</a>
</nav>
<%
}
%>
</div>
</header>
<section class="banner">
<div class="container">
<div>
<h1>慕课网留言板</h1>
<p>慕课网是垂直的互联网IT技能免费学习网站。以独家视频教程、在线编程工具、学习计划、问答社区为核心特色。在这里,你可以找到最好的互联网技术牛人,也可以通过免费的在线公开视频课程学习国内领先的互联网IT技术。
</p>
</div>
</div>
</section>
<section class="main">
<div class="container">
<c:forEach var="message" items="${pageBean.list }">
<div class="alt-item">
<div class="alt-head">
<div class="alt-info">
<span>${message.user.username}<a href=""></a></span> <span>${message.create_time }</span>
</div>
</div>
<div class="alt-content">
<h3>${message.title }</h3>
<p>${message.content}</p>
</div>
</div>
</c:forEach>
</div>
</section>
<section class="page">
<div class="container">
<div id="pagefy">
<ul>
<c:if test="${ pageBean.page != 1 }">
<li><a
href="${pageContext.request.contextPath }/IndexServlet?page=1">首页</a></li>
<li><a
href="${pageContext.request.contextPath }/IndexServlet?page=${pageBean.page-1}">上一页</a></li>
</c:if>
<c:forEach var="i" begin="1" end="${pageBean.totalPage }">
<c:if test="${ pageBean.page == i }">
<li><span class="first-page">${ i }</span></li>
</c:if>
<c:if test="${ pageBean.page != i }">
<li><a
href="${ pageContext.request.contextPath }/IndexServlet?page=${ i }">${ i }</a></li>
</c:if>
</c:forEach>
<c:if test="${ pageBean.page != pageBean.totalPage }">
<li><a
href="${pageContext.request.contextPath }/IndexServlet?page=${pageBean.page+1}">下一页</a></li>
<li><a
href="${pageContext.request.contextPath }/IndexServlet?page=${pageBean.totalPage}">尾页</a></li>
</c:if>
</ul>
</div>
<!-- 分页内容参考视频中老师源码 -->
<div class="container">
<%
if (request.getSession().getAttribute("existUser") != null) {
%>
<nav>
<a href="${pageContext.request.contextPath}/add_message.jsp">点我留言</a>
</nav>
<%
} else {
%>
<nav>
<a href="${pageContext.request.contextPath}/login.jsp">请登录后留言</a>
</nav>
<%
}
%>
</div>
</div>
</section>
<footer> copy@慕课网 </footer>
</body>
</html>
package com.imooc.domain;
import java.util.List;
public class PageBean<T> {
private int page; //当前的页数
private int limit; // 每页显示的记录数
private int totalCount; // 总记录数
private int totalPage; // 总页数
private List<T> list; // 每页显示的数据的集合
public PageBean() {
super();
}
public PageBean(int page, int limit, int totalCount, int totalPage, List<T> list) {
super();
this.page = page;
this.limit = limit;
this.totalCount = totalCount;
this.totalPage = totalPage;
this.list = list;
}
public int getPage() {
return page;
}
public void setPage(int page) {
this.page = page;
}
public int getLimit() {
return limit;
}
public void setLimit(int limit) {
this.limit = limit;
}
public int getTotalCount() {
return totalCount;
}
public void setTotalCount(int totalCount) {
this.totalCount = totalCount;
}
public int getTotalPage() {
return totalPage;
}
public void setTotalPage(int totalPage) {
this.totalPage = totalPage;
}
public List<T> getList() {
return list;
}
public void setList(List<T> list) {
this.list = list;
}
@Override
public String toString() {
return "PageBean [page=" + page + ", limit=" + limit + ", totalCount=" + totalCount + ", totalPage=" + totalPage
+ ", list=" + list + "]";
}
}
package com.imooc.web.action;
import java.io.IOException;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.imooc.domain.Message;
import com.imooc.domain.PageBean;
import com.imooc.service.MessageService;
import com.imooc.service.impl.MessageServiceImpl;
@WebServlet("/IndexServlet")
public class IndexServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
int page = 0;
String currPage = request.getParameter("page");
if (currPage == null||Integer.parseInt(currPage)<0) {
page = 1;
} else {
page = Integer.parseInt(currPage);
}
// 查询操作
MessageService messageService=new MessageServiceImpl();
PageBean<Message> pageBean = messageService.findByPage(page);
//页面跳转
request.setAttribute("pageBean", pageBean);
request.getRequestDispatcher("/message_list.jsp").forward(request, response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doGet(request, response);
}
}
正在回答
同学你好,同学可以在MySQL工具中手动调整输入一下时间
如上所示操作后再来尝试一下,看是否有正常的时分秒的数据。
- 参与学习 人
- 提交作业 357 份
- 解答问题 8016 个
本阶段将带你学习MySQL数据库,JDBC接口,MyBatis框架等,带你掌握的数据的存放和管理。
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星