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 ...
随机推荐
- 『个人の笔记』百度ife
✄--------------------------------------------task1分割线--------------------------------------------✄ 百 ...
- 提高测试脚本复用性降低DOM结构引起路径变化的影响
问题描述 在定位元素时直接复制的xpath. 但是因为下面这些原因导致之前引用的路径失效, 不得不频繁修改脚本重新定位元素, 大降低了脚本的复用性, 也增加了维护的成本: 1. UI修改 (比如增加了 ...
- Elasticsearch笔记二之Curl工具基本操作
Elasticsearch笔记二之Curl工具基本操作 简介: Curl工具是一种可以在命令行访问url的工具,支持get和post请求方式.-X指定http请求的方法,-d指定要传输的数据. 创建索 ...
- 单机部署-consul
在本机开发环境中,直接通过以下命令可以启动一个单机consul服务器: ./consul agent -server -data-dir=/tmp/consul -bootstrap -adverti ...
- mysql主从复制搭建
1.准备工作: 准备一台主服务器,我的IP地址为192.168.13.138,和一台从服务器:192.168.13.137,数据库版本一致,主从库都建好相应的库和表: 2.修改主从服务器的mysql配 ...
- 一步一步理解 python web 框架,才不会从入门到放弃 -- 开始使用 Django
背景知识 要使用 Django,首先必须先安装 Django. 下图是 Django 官网的版本支持,我们可以看到上面有一个 LTS 存在.什么是 LTS 呢?LTS ,long-term suppo ...
- 【源码】otter工程结构
最近在搞数据同步相关的内容,需要对otter的代码进行扩展,所以需要先熟悉一下otter的源码.首先我们整体来看下otter的工程结构.otter的工程结构比较复杂,需要花费一定的时间来理解各个部分的 ...
- BZOJ_1180_[CROATIAN2009]OTOCI_LCT
BZOJ_1180_[CROATIAN2009]OTOCI_LCT Description 给出n个结点以及每个点初始时对应的权值wi.起始时点与点之间没有连边.有3类操作: 1.bridge A ...
- 教你如何使用Java手写一个基于链表的队列
在上一篇博客[教你如何使用Java手写一个基于数组的队列]中已经介绍了队列,以及Java语言中对队列的实现,对队列不是很了解的可以我上一篇文章.那么,现在就直接进入主题吧. 这篇博客主要讲解的是如何使 ...
- SpringBoot进阶教程(三十)整合Redis之Sentinel哨兵模式
Redis-Sentinel是官方推荐的高可用解决方案,当redis在做master-slave的高可用方案时,假如master宕机了,redis本身(以及其很多客户端)都没有实现自动进行主备切换,而 ...