1>使用Maven下载:
<!--用于日期datetimepicker https://mvnrepository.com/artifact/org.apache.struts/struts2-dojo-plugin -->
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-dojo-plugin</artifactId>
<version>2.3.34</version>
</dependency>
2>在jsp中引入tag:
在<head></head>中加入<sx:head />,<SX:HEAD/>的作用是自动导入struts2 dojo的js和css
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sx" uri="/struts-dojo-tags"%>
<sx:head parseContent="true"/>
3>使用datetimepicker标签
<sx:datetimepicker name="date1" label="Format (dd-MMM-yyyy)"
displayFormat="dd-MMM-yyyy" value="%{'today'}" /><p/>
<sx:datetimepicker value="%{'2007-01-01'}"/>
4>运行但不显示日期哦!通过查看页面源码发现下面的代码都已经生成,但是直接开发现资源不存在
遇到这种情况的时候,请检查web.xml的struts配置,假如struts filter的mapping不是对所有url过滤,
加入/struts/* 过滤就OK
显示效果: