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 ...
随机推荐
- 跟我学ASP.NET MVC之四:使用Razor
摘要: 视图引擎处理ASP.NET内容,并查找指令,典型情况是向浏览器输出插入动态内容.MVC框架视图引擎的名字是Razor. 在本文中,我将带领读者快速认识Razor,以后你们看到他们的时候能够认识 ...
- python 3.6 lxml标准库lxml的安装及etree的使用注意
据我所知,python 3.5之后的lxml模块里面不再包含etree,那么要怎么解决这个问题呢? lxml模块下的etree函数的使用问题,部分lxml模块不再支持etree方法,因此只能想办法下载 ...
- 【bzoj3598】: [Scoi2014]方伯伯的商场之旅
Description 方伯伯有一天去参加一个商场举办的游戏.商场派了一些工作人员排成一行.每个人面前有几堆石子.说来也巧,位置在 i 的人面前的第 j 堆的石子的数量,刚好是 i 写成 K 进制后的 ...
- bzoj 2242 [SDOI2011]计算器 快速幂+扩展欧几里得+BSGS
1:快速幂 2:exgcd 3:exbsgs,题里说是素数,但我打的普通bsgs就wa,exbsgs就A了...... (map就是慢)..... #include<cstdio> # ...
- 【源码解析】Sharding-Jdbc的执行过程(一)
一.ShardingContext 在Sharding-Jdbc中,我们其实需要抓住一个核心类,也就是ShardingContext,分片上下文,里面定义了下面几个内容: @RequiredArgsC ...
- LOJ_2305_「NOI2017」游戏 _2-sat
LOJ_2305_「NOI2017」游戏 _2-sat 题意: 给你一个长度为n的字符串S,其中第i个字符为a表示第i个地图只能用B,C两种赛车,为b表示第i个地图只能用A,C两种赛车,为c表示第i个 ...
- NavigationView头部设置监听事件
直接写解决方法吧: 1.将XML里的静态引入删除: <android.support.design.widget.NavigationView android:id="@+id/nav ...
- Eclipse Debug调试遇到的问题
在使用Debug模式前,一定要先打好断点.快捷调试方法: 在使用过程中,可以只保留Console,Variables,Debug窗口,把其他无用的窗口最小化掉,或者删掉即可.如果要恢复删掉的试图, ...
- .net core 并发下的线程安全问题
抱歉,其实内容并不如题!!!真正的题目应该为<.net core 并发下由于注入模式引起的线程安全问题> 背景(写测试demo所出现的异常,供大家学习与拍砖): .net core web ...
- Java进阶篇设计模式之十三 ---- 观察者模式和空对象模式
前言 在上一篇中我们学习了行为型模式的备忘录模式(Memento Pattern)和状态模式(Memento Pattern).本篇则来学习下行为型模式的最后两个模式,观察者模式(Observer P ...