Struts2日期控件datatimepicker不能正常显示的问题

2014-11-24 02:25:21 · 作者: · 浏览: 0

最近有一个项目使用了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" %>

    
        注册
        
  
        
  
    
    
	
  
    
结果日历框就是不显示,在 FF和猎豹下也不报错,后来在IE8下发现了报错:

'djConfig.searchIds' 为空或不是对象

感觉很奇怪,不知道是哪里配置有问题,心想不会是 struts配置文件的问题吧,经过了不断的尝试,最后在网上找到一段资料

struts tags的使用要求:

Struts tags are only usable when the request has passed through its servlet filter

需要把dojo的文件也通过struts2的servlet filter才能被正常引用。

原来我最开始的struts mapping只配置了

        
  
		
   
    struts2
   
		
   
    *.action
   
        
  

生成的代码是像这样的





所以我要增加一段 mapping

  
	    
   
    struts2
   
	    
   
    /struts/*
   
	
  

加上这段后,一切正常了。