zoukankan      html  css  js  c++  java
  • applicationContext.xml

    严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
    org.springframework.beans.factory.BeanDefinitionStoreException: 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]
     at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:341)
     at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
     at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
     at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)
     at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149)
     at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:124)
     at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:93)
     at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)
     at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:467)
     at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:397)
     at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
     at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
     at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
     at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4790)
     at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5284)
     at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
     at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1595)
     at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1585)
     at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
     at java.util.concurrent.FutureTask.run(Unknown Source)
     at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
     at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
     at java.lang.Thread.run(Unknown Source)
    Caused by: java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/applicationContext.xml]
     at org.springframework.web.context.support.ServletContextResource.getInputStream(ServletContextResource.java:117)
     at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:328)
     ... 22 more

    遇到的新报错。

    我看的是mvc 的例子,是不是因为spring的版本不同?需要加服务层配置文件?bean 里面的的这么多像网址一样的是什么意思?

    需要加下context-param

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
       classpath:/net/spring/controller/context-common.xml
      </param-value>
      </context-param>

    贴下web.xml

    <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">

    <display-name>Spring3MVC</display-name>   <context-param>     <param-name>contextConfigLocation</param-name>     <param-value>    classpath:/net/spring/controller/context-common.xml   </param-value>   </context-param>     <listener>   <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>  </listener>      <servlet>     <servlet-name>spring</servlet-name>     <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>     <init-param>       <param-name>contextConfigLocation</param-name>       <param-value>classpath:/net/spring/controller/spring-servlet.xml</param-value>     </init-param>      <load-on-startup>1</load-on-startup>    </servlet>    <servlet-mapping>     <servlet-name>spring</servlet-name>      <url-pattern>*.do</url-pattern>   </servlet-mapping>    

    </web-app> 

    spring-servlet

    <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context"    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/context   http://www.springframework.org/schema/context/spring-context-2.5.xsd">  

    <context:component-scan base-package="net.spring.controller"/> <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"/> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"  p:suffix=".jsp"/>

    </beans>

    package net.spring.controller;

    import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.servlet.ModelAndView;

    @Controller @RequestMapping(value = "/test.do") public class HelloWorldController {       @RequestMapping  public String test(){      String message="Hello World,Spring 3.0";   System.out.println(message);   //return new ModelAndView("hello","message",message);   return "test";  }

    }

  • 相关阅读:
    iOS 9之后Url链接的NSUTF8StringEncoding转码实现
    iOS实现应用更新及强制更新
    Objective-C代码简写
    Mac下使用数据库将Excel数据转换存入.plist
    iOS开发之图片压缩实现
    iOS键盘事件实现、控制
    iOS 轻击、触摸和手势的检测
    使用CocoaPods时遇到 Permission denied 问题
    2016-3-1 Mac下使用Hexo搭建Blog
    2016-3-1 安装Hexo过程中遇到的问题
  • 原文地址:https://www.cnblogs.com/lauraxia/p/2922236.html
Copyright © 2011-2022 走看看