zoukankan      html  css  js  c++  java
  • 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.1lib下是没有的,需要在struts-2.2.1appsstruts2-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>

  • 相关阅读:
    Orac and Medians
    牛牛的揠苗助长
    Color Graph
    Spanning Tree Removal【构造】
    A Simple Problem On A Tree
    Spring源码学习笔记(六、Spring启动流程解析:BeanFactory后置处理)
    Spring源码学习笔记(五、Spring启动流程解析:准备BeanFactory)
    一、求最大公约数
    Spring源码学习笔记(四、Spring启动流程解析:概述与准备上下文、获取BeanFactory)
    Spring源码学习笔记(三、路径和占位符,Spring容器如何解析配置信息)
  • 原文地址:https://www.cnblogs.com/yuan1225/p/3316162.html
Copyright © 2011-2022 走看看