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 ...
随机推荐
- java基础之修饰符和内部类
1.java修饰符 /* 修饰符: 权限修饰符:private,默认的,protected,public 状态修饰符:static,final 抽象修饰符:abstract 类: 权限修饰符:默认修饰 ...
- Django+Bootstrap+Mysql 搭建个人博客(六)
6.1.comments插件 (1)安装 pip install django-contrib-comments (02)settings INSTALLED_APPS = [ 'django.con ...
- python使用随机的163账号发送邮件
import linecache import smtplib import time import linecache import random #算出txt的行数,163账号_2.txt中,每一 ...
- python 产生token及token验证
1.前言 最近在做微信公众号开发在进行网页授权时,微信需要用户自己在授权url中带上一个类似token的state的参数,以防止跨站攻击.在经过再三思考之后,自己试着实现一个产生token和验证tok ...
- SQL Server 日志和代理的错误日志
本文介绍的日志不是事务日志,而是SQL Server 日志和代理的错误日志,按照主体把错误日志分为SQL Server.SQL Server Agent.Database Mail,以及 Window ...
- 运用BT在centos下搭建一个博客论坛
在日常的工作和学习中,我们都很希望有自己的工作站,就是自己的服务器,自己给自己搭建一个博客或者是论坛,用于自己来写博客和搭建网站论坛.现在我们就用一个简单的方法来教大家如何30分钟内部署一个博客网站. ...
- c# 如何找到项目中图片的相对路径
c# 如何找到项目中图片的相对路径 string path = System.Environment.CurrentDirectory;//非Web程序if (System.Environment.C ...
- Angularjs interceptor
angularJs 请求过滤 新建一个服务, $HttpProvider 中有一个 interceptore 数组,所谓的拦截器就是一个注册到该数组的工厂,该工厂在app.config() 中注入, ...
- SQL Server 锁详解
锁是一种防止在某对象执行动作的一个进程与已在该对象上执行的其他进行相冲突的机制.也就是说,如果有其他人在操作某个对象,那么你旧不能在该对象上进行操作.你能否执行操作取决于其他用户正在进行的操作. 通过 ...
- javascript && php &&java 轰炸!!!
java && javascript && php 轰炸!!!恢复 1.javascript简介 *是基于对象和时间的驱动语言,应用于客户端. -----基于对象: * ...