最近有一个项目使用了struts2,用到了日是期控件,我用的是2.2.1版本。
代码如下,只截了最简单的代码示例
<%@ page contentType="text/html; charset=gb2312" pageEncoding="gb2312"%> <%@taglib prefix="s" uri="/struts-tags"%> <%@ taglib prefix="sx" uri="/struts-dojo-tags" %> <html> <head> <title>注册</title> <s:head theme="xhtml"/> <sx:head extraLocales="UTF-8"/> </head> <body> <sx:datetimepicker value="%{‘2007-01-01‘}" name="picker" /> </body> </html>结果日历框就是不显示,在 FF和猎豹下也不报错,后来在IE8下发现了报错:
struts tags的使用要求:
Struts tags are only usable when the request has passed through its servlet filter
需要把dojo的文件也通过struts2的servlet filter才能被正常引用。
原来我最开始的struts mapping只配置了
<filter-mapping> <filter-name>struts2</filter-name> <url-pattern>*.action</url-pattern> </filter-mapping>而
<sx:head />生成的代码是像这样的
<script language="JavaScript" src="/dzdx/struts/utils.js" type="text/javascript"></script> <script language="JavaScript" src="/dzdx/struts/xhtml/validation.js" type="text/javascript"></script> <script language="JavaScript" src="/dzdx/struts/css_xhtml/validation.js" type="text/javascript"></script>
<filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/struts/*</url-pattern> </filter-mapping>
Struts2日期控件datatimepicker不能正常显示的问题,布布扣,bubuko.com
Struts2日期控件datatimepicker不能正常显示的问题
原文:http://blog.csdn.net/fireofjava/article/details/19927899