鉴于很多人说Intellij IDEA 非常好用,我也开始了我的IDEA之旅。作为一名Eclipse的使用者,旅途中自是各种曲折。比如说今天用这个学习研究struts2真是烦不胜烦。
<s:datetimepicker/>的问题
刚开始导了/struts-tags之后发现没有<s:datetimepicker/>这个标签
原因:Strust2.1开始,对于ajax类的标签不再使用<%@ taglib prefix="s" uri= "/struts-tags"%> 引用
具体原因我就不多说了详情请见大神博客:http://www.th7.cn/Program/java/201406/221080.shtml
这位大神讲的非常详细,有一点补充的是:我们如何知道对应pojo-plugin版本和struts的版本呢?
打开这个dojo-plugin.jar里面的struts-plugin.xml
这个就是你所需要的版本号,所以我maven配置了这个版本。这个问题解决
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>2.3.24.1</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-dojo-plugin</artifactId>
<version>2.3.24.1</version>
</dependency>
两个东西 "/struts-tags" not found 、"/struts-dojo-tags" not found
刚开始百度,google各种答案:大概的意思是把这两个对应的tld放在WEB-INF目录下面,然后在web.xml中手动指定。
<taglib>
<taglib-uri>/struts-tags</taglib-uri>
<taglib-location>/WEB-INF/struts-tags.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/struts-dojo-tags</taglib-uri>
<taglib-location>/WEB-INF/struts-dojo-tags.tld</taglib-location>
</taglib>
然而我按照上述办法弄了之后还是没能解决我的问题。。。。。。
后面看了有位大神的文章之后很有启发,虽然那位大神没有给出解决办法,但是还是谢谢那位大神。下面给出大神的博客:Struts2的dojo使用与/template/ajax/head.ftl not found.
最后几经波折终于解决了问题:
主要原因是我是在原来project下新建的一个module(IDEA的project相当于原来的workspace),当前module中依赖的是原来project的包。把依赖改为自己的依赖就可以解决问题。
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>2.3.24.1</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-dojo-plugin</artifactId>
<version>2.3.24.1</version>
</dependency>