前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >struts2框架搭建学习遇到的问题

struts2框架搭建学习遇到的问题

作者头像
yuanyuan
发布2019-09-10 18:11:14
4940
发布2019-09-10 18:11:14
举报
文章被收录于专栏:小满小满

遇到的两个问题

1Dispatcher initialization failed:

严重: Dispatcher initialization failed java.lang.RuntimeException: java.lang.reflect.InvocationTargetException处理方法:

1、核对lib包commons-fileupload-1.2.1.jar,commons-io-1.3.2.jar commons-logging-1.0.4.jar freemarker-2.3.16.jar ognl-3.0.jar struts2-core-2.2.1.jar xwork-core-2.2.1.jar注意2.1以前是没有commons-fileupload-1.2.1.jar,

2、如果struts2版本是2.1以前web.xml配置过滤器的时候应该是这样: indexstruts2 org.apache.struts2.dispatcher.FilterDispatcher struts2/*如果struts2 版本是2.1以上web.xml配置 index.jspstruts2org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilterstruts2/*

3、 在使用struts-2.2.1时,需要引入javassist-3.7.ga.jar,而这个在struts-2.2.1\lib下是没有的,需要在struts-2.2.1\apps\struts2-blank-2.2.1.war下的lib中找。

我的项目中缺少commons-io-1.3.2.jar 和javassist-3.7.ga.jar包 ,将这两个包添加上就不再出现这个问题了

但是又出现了一个新的问题

NoClassDefFoundError: org/apache/commons/lang3/StringUtils。。。

Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang3.StringUtils。。。

添加commons-lang3-3.1.jar包,注意不是缺少commons-lang-2.4.jar造成的,而是commons-lang3-xx.jar造成的,第一次我添加了commons-lang-2.4.jar还是出现同样的问题,又仔细看了看错误明明是 xxx.commons.lang3.xxx,所以添加一个commons-lang3包就OK了

这些问题都修改好了之后,在Struts.xml中添加了Action的配置,配置之后就出现了一下问题:

Dispatcher initialization failed Unable to load configuration. - action - file:/E:/lewan/project/.metadata/.plugins/org.eclipse.wst.server.core/tmp2/wtpwebapps/Struts2Demo/WEB-INF/classes/struts.xml:12:58

.....

Caused by: Action class [com.lw.struts.LoginAction] not found - action - file:/E:/lewan/project/.metadata/.plugins/org.eclipse.wst.server.core/tmp2/wtpwebapps/Struts2Demo/WEB-INF/classes/struts.xml:12:58

添加了一个包之后又出现 了

Unable to load configuration. - bean - jar:file:/E:/lewan/project/.metadata/.plugins/org.eclipse.wst.server.core/tmp2/wtpwebapps/Struts2Demo/WEB-INF/lib/struts2-spring-plugin-2.3.15.1.jar!/struts-plugin.xml:29:132 at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:70)

。。。。Caused by: Unable to load bean: type:com.opensymphony.xwork2.ObjectFactory class:org.apache.struts2.spring.StrutsSpringObjectFactory - bean - jar:file:/E:/lewan/project/.metadata/.plugins/org.eclipse.wst.server.core/tmp2/wtpwebapps/Struts2Demo/WEB-INF/lib/struts2-spring-plugin-2.3.15.1.jar!/struts-plugin.xml:29:132

Caused by: java.lang.NoClassDefFoundError: org/springframework/context/ApplicationContextAware

。。添加spring相关的包

IOException parsing XML document from ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/applicationContext.xml]

webml中添加 <context-param> <param-name>contextConfigLocation </param-name> <param-value>/WEB-INF/classes/applicationContext.xml </param-value> </context-param>

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2013-09-12 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档