struts 为什么用org.springframework.web.context.ContextLoaderListener才不会出错,郁闷知道的能说下吗,谢谢

解决方案 »

  1.   

    就是web.xml里要加入
    <listener>

    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>

    </listener>
    而且要在lib下建立applicationContext.xml文件在这里struts和spring有什么关系
      

  2.   

    web.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
    http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <filter>
    <filter-name>struts2</filter-name>
    <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
    </filter> <filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>*.action</url-pattern>
    </filter-mapping>
    <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
    </web-app>
      

  3.   

    struts.xml
    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE struts PUBLIC
        "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
        "http://struts.apache.org/dtds/struts-2.0.dtd">
    <struts>
    <package name="ot" extends="struts-default">
    <action name="hello" class="HelloAction">
    <result name="success">/index.jsp</result>
    </action>
    </package></struts>
      

  4.   

    哈哈,这个我只得到:你的jar包里struts2-spring-plugin-2.0.11.1.jar
    如果你不用spring  就把类似这个包去掉
    如果你用spring就一定要加org.springframework.web.context.ContextLoaderListener 这个监听