struts2框架搭建学习遇到的问题
遇到的两个问题
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>
struts2框架搭建学习遇到的问题的更多相关文章
- Struts2框架搭建
使用Struts2版本为:struts-2.3.16.3 下载地址:http://struts.apache.org/ 一.向web项目中添加struts2依赖库 commons-fileupload ...
- struts2框架搭建(一)
struts2是一个基于mvc的web应用框架.struts2本质上相当于一个servlet,在MVC设计模式中,Struts2作为控制器层(Controller)来建立模型与视图的数据交互. str ...
- 一周一话题之一(EF-CodeFirst、MEF、T4框架搭建学习)
本话题是根据郭明峰博客<MVC实用架构系列>的搭建学习总结. -->目录导航 一.数据仓储访问的构建 1.UnitOfWork的构建 2.Repository的构建 ...
- mybatis框架搭建学习初步
mybatis框架搭建步骤:1. 拷贝jar到lib目录下,而且添加到工程中2. 创建mybatis-config.xml文件,配置数据库连接信息 <environments default=& ...
- 《转》Spring4 Freemarker框架搭建学习
这里原帖地址:http://www.cnblogs.com/porcoGT/p/4537064.html 完整配置springmvc4,最终视图选择的是html,非静态文件. 最近自己配置spring ...
- struts2框架概述
框架概述 什么是框架,为什么使用框架,框架优点 框架(framework)是一个基本概念上的结构,用于去解决或者处理复杂的问题 框架,即framework.其实就是某种应用的半成品,就是一组组件,供你 ...
- struts2的搭建和简单的例子(采用struts-2.5.2版本)
struts框架的概述: 当2001年初,Struts的第一个版本在apache网站上发布,它提供了一种分离视图和业务应用逻辑的web应用方案. 在Struts诞生之前,开发人员都是在jsp里写入处理 ...
- struts2框架学习笔记1:搭建测试
Servlet是线程不安全的,Struts1是基于Servlet的框架 而Struts2是基于Filter的框架,解决了线程安全问题 因此Struts1和Struts2基本没有关系,只是创造者取名问题 ...
- Struts2框架学习(一)——Struts2的概念及搭建
一.Struts2的概念 使用优势:1)自动封装参数 2)参数校验 3)结果的处理(转发|重定向) 4)国际化 5)显示等待页面 6)防止表单重复提交 Struts2具有更加先进的架构以及思想 Str ...
随机推荐
- Jenkins持续集成项目搭建与实践——基于Python Selenium自动化测试(自由风格)
Jenkins简介 Jenkins是Java编写的非常流行的持续集成(CI)服务,起源于Hudson项目.所以Jenkins和Hudson功能相似. Jenkins支持各种版本的控制工具,如CVS.S ...
- 【BZOJ 2744】【HEOI2012】朋友圈
题目链接: TP 题解: 对于A国,我们发现,最大团一定不大于2.对于B国,发现同奇偶性点之间都有边,不同奇偶性之间可能有边,也就是说对于B国是一个二分图最大团,也就是求B国补图的二分图最大独立集.然 ...
- 【数学建模】【APIO2015】Palembang Bridges
Description 一条东西走向的穆西河将巴邻旁市一分为二,分割成了区域 A 和区域 B. 每一块区域沿着河岸都建了恰好 1000000001 栋的建筑,每条岸边的建筑都从 0 编号到 10000 ...
- BZOJ_3012_[Usaco2012 Dec]First!_trie树+拓扑排序
BZOJ_3012_[Usaco2012 Dec]First!_trie树+拓扑排序 题意: 给定n个总长不超过m的互不相同的字符串,现在你可以任意指定字符之间的大小关系.问有多少个串可能成为字典序最 ...
- BZOJ 1260:[CQOI2007]涂色paint
(⊙o⊙)-,常规课考试又炸了!目测此次我要完蛋了... 又玩脱了,考数学的时候装B装大了! 算了,先进入正题... 题目描述:Description假设你有一条长度为5的木版,初始时没有涂过任何颜色 ...
- 设置yum源:
1.企业 阿里开源镜像站: http://mirrors.aliyun.com/ 搜狐开源镜像站: http://mirrors.sohu.com/ 网易开源镜像站: http://mirr ...
- 毕业样本=[华威大学毕业证书]Warwick原件一模一样证书
华威大学毕业证[微/Q:2544033233◆WeChat:CC6669834]UC毕业证书/联系人Alice[查看点击百度快照查看][留信网学历认证&博士&硕士&海归& ...
- setContentType与setCharacterEncoding的区别
setCharacterEncoding只是设置字符的编码方式 setContentType除了可以设置字符的编码方式还能设置文档内容的类型 1.setCharacterEncoding respon ...
- Sublime text3所遇到的问题
sublime text3的下载地址:https://www.sublimetext.com/ 解决sublime text上不能使用交互的input的输入问题 通过安装sublimeREPL插件解决 ...
- js 的 骚操作
单行的js 代码虽然简洁,但却不易维护,甚至难以理解, 但这却并不影响前端童鞋们编写简洁代码的热情, 一 , 生成随机ID // 生成长度为10的随机字母数字字符串 Math.random().t ...