oracle数据库中crtdate存储类型为date类型:
存储形式:
model类中存储类型为date类型,注意导包是util包下的:
java后台:
@RequestMapping("/prepdt")
public String prepdt(
@RequestParam(value = "pageNumber", required = false, defaultValue = "1")int pageNumber,
@RequestParam(value = "pageSize", required = false, defaultValue = "10")int pageSize,
@RequestParam(value = "pdtname", required = false, defaultValue = "") String pdtname,
@RequestParam(value = "pdtcode", required = false, defaultValue = "") String pdtcode,
@RequestParam(value = "pdtitem", required = false, defaultValue = "") String pdtitem,
@RequestParam(value = "startDate", required = false, defaultValue = "") String startDate,
@RequestParam(value = "endDate", required = false, defaultValue = "") String endDate,
Model model,HttpSession session) throws Exception{
pdtname=pdtname.trim();
pdtcode=pdtcode.trim();
List<Product> pdtList =productService.queryAllProductionByPage(pageNumber,pageSize,pdtname,pdtcode,startDate,endDate,pdtitem);
System.out.println(pdtList.get(0).getCrtdate());
int allcount=productService.queryAllProductionNum(pdtname, pdtcode, startDate, endDate,pdtitem);
model.addAttribute("allcount", allcount);
model.addAttribute("list", pdtList);
model.addAttribute("pageNumber", pageNumber);
model.addAttribute("pageSize", pageSize);
model.addAttribute("pdtname", pdtname);
model.addAttribute("pdtcode", pdtcode);
model.addAttribute("pdtitem", pdtitem);
model.addAttribute("startDate", startDate);
model.addAttribute("endDate", endDate);
return "product/pdtlist2";
}
控制台打印出来的crtdate的值:Mon Sep 25 18:47:32 CST 2017
前台显示:
<c:forEach items="${list }" var="l">
<tr style="border: ">
<td bgcolor="#FFFFFF" class="headtd"> ${l.pdtcode }</td>
<td bgcolor="#FFFFFF" class="headtd"> ${l.pdtitem }</td>
<td bgcolor="#FFFFFF" class="headtd"> ${l.pdtname }</td>
<td bgcolor="#FFFFFF" class="headtd"> <fmt:formatDate value="${l.crtdate}" type="both" /></td>
<td bgcolor="#FFFFFF" style="padding-top: 15px;padding-bottom: 15px;" class="headtd">
${l.crtrealname }
</td>
<td bgcolor="#FFFFFF" class="headtd">
<a href="javascript:void(0)" onclick="update('${l.id}')"><img src="<%=basePath%>static/img/edit.png">修改</a>
<a href="javascript:void(0)" onclick="remove('${l.id}')"><img src="<%=basePath%>static/img/edit.png">删除</a>
</td>
</tr>
</c:forEach>
使用jstl的标签:<fmt:formatDate value="${l.crtdate}" type="both" />
显示:
关于fmt:formatDate标签的使用:http://www.runoob.com/jsp/jst...