在Strust2 使用datatimepicker 标签引发的一系列问题

问题:出现无法识别的问题

原因:Strust2.1开始,对于ajax类的标签不再使用<%@ taglib prefix="s" uri="/struts-tags"%> 引用

而是<%@ taglib prefix="sd" uri="/struts-dojo-tags"%>  

解决方法:WEB-INF/lib下面添加struts2-dojo-plugin.jar包;,然后像类似这样的代码

<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>  
<%@ taglib prefix="s" uri="/struts-tags"%>  
<%@ taglib prefix="sx" uri="/struts-dojo-tags"%>  
<html>  
<head>  
<sx:head />  
</head>  
<body>  
  
<s:form method="post" theme="simple">  
    <sx:datetimepicker name="startDate" toggleType="explode"  
        toggleDuration="400" displayFormat="yyyy-MM-dd" id="start"  
        value="today" label="date">  
    </sx:datetimepicker>  
    <s:submit value="submit"></s:submit>  
  
</s:form>  
  
</body>  

 这个时候出现了新问题:

运行报错:

Unable to load configuration. - bean - jar:file:/E:/Program%20Files/apache-tomcat-8.0.3/webapps/web/WEB-INF/lib/struts2-dojo-plugin-2.3.16.1.jar!/struts-plugin.xml:29:136
 
原因:
struts2.3.16.xx版本把相关类进行了修改(改为 <bean type="org.apache.struts2.views.TagLibraryDirectiveProvider" name="sx" class="org.apache.struts2.dojo.views.DojoTagLibrary" /
 
 
当你使用的Strust2-dojo-plugin.jar的版本过低,比喻Strust2 使用的是2.3.16.2,而你的Strust2-dojo-plugin是2.3.4时就会找不到类。
Strust2-dojo-plugin 2.3.4 的Strust-plugin文件:
<struts>
<bean type="org.apache.struts2.views.TagLibrary" name="sx" class="org.apache.struts2.dojo.views.DojoTagLibrary"/>
</struts>

 

Strust2 2.3.16.1版本中已经改为

办法就是使用一个跟你使用的Strust2版本相符的Strust2-dojo-plugin版本的jar

下载地址

http://repo1.maven.org/maven2/org/apache/struts/struts2-dojo-plugin/

posted @ 2014-06-23 00:53  Genji_  阅读(860)  评论(0编辑  收藏  举报