1、pom.xml添加依赖
<dependency> <groupId>velocity-tools</groupId> <artifactId>velocity-tools</artifactId> <version>1.4</version> </dependency>
2、页面处理程序加入如下语句:
import org.apache.velocity.tools.generic.DateTool; context.put("date", new DateTool()); //SpringMVC中这样写 modelAndView.addObject("date", new DateTool());
3.页面模板中这样写:
$!date.format('yyyy-MM-dd HH:mm:ss',$!articleDetail.publicTime)