http://blog.csdn.net/wlwlwlwl015/article/details/48134763

Maven 项目的 classpath 理解

applicationContext.xml放在maven的src/main/resources下,将web.xml中的<param-value>配置如下。

<servlet>
<servlet-name>springMvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>

如下异常:Could not open ServletContext resource [/WEB-INF/applicationContext.xml

原因:如果不特意指定参数名为contextConfigLoction的<context-parameter>元素,那么spring的ContextLoderListener监听器就会在/WEB-INF/下去寻找并加载该目录下的名为applicationContext.xml这个文件。

解决:

 <context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param> <listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

spring中classpath的更多相关文章

  1. Spring 中classPath:用法

    参考文章地址: http://hi.baidu.com/huahua035/item/ac8a27a994b55bad29ce9d39 http://blog.csdn.net/lushuaiyin/ ...

  2. Spring中 classpath* 和 classpath 前缀的区别

    // org.springframework.core.io.support.ResourcePatternResolver /** * Pseudo URL prefix for all match ...

  3. Spring core resourc层结构体系及JDK与Spring对classpath中资源的获取方式及结果对比

    1. Spring core resourc层结构体系 1.1. Resource相关结构体系 1.2. ResourceLoader相关体系 2. JDK与Spring对classpath中资源的获 ...

  4. Spring MVC-从零开始-web.xml中classpath和classpath* 有什么区别

    web.xml中classpath和classpath* 有什么区别?classpath:只会到你的class路径中查找找文件;classpath*:不仅包含class路径,还包括jar文件中(cla ...

  5. Velocity初探小结--Velocity在spring中的配置和使用

    最近正在做的项目前端使用了Velocity进行View层的数据渲染,之前没有接触过,草草过了一遍,就上手开始写,现在又回头细致的看了一遍,做个笔记. velocity是一种基于java的模板引擎技术, ...

  6. Spring中常见的bean创建异常

    Spring中常见的bean创建异常 1. 概述     本次我们将讨论在spring中BeanFactory创建bean实例时经常遇到的异常 org.springframework.beans.fa ...

  7. Quartz 在 Spring 中如何动态配置时间--转

    原文地址:http://www.iteye.com/topic/399980 在项目中有一个需求,需要灵活配置调度任务时间,并能自由启动或停止调度. 有关调度的实现我就第一就想到了Quartz这个开源 ...

  8. Spring中文文档

    前一段时间翻译了Jetty的一部分文档,感觉对阅读英文没有大的提高(*^-^*),毕竟Jetty的受众面还是比较小的,而且翻译过程中发现Jetty的文档写的不是很好,所以呢翻译的兴趣慢慢就不大了,只能 ...

  9. [原创]java WEB学习笔记109:Spring学习---spring中事物管理

    博客的目的:①总结自己的学习过程,相当于学习笔记 ②将自己的经验分享给大家,相互学习,互相交流,不可商用 内容难免出现问题,欢迎指正,交流,探讨,可以留言,也可以通过以下方式联系. 本人互联网技术爱好 ...

随机推荐

  1. 关于easy ui 的combobox遍历选中

    $.post("fleetAction!queryAllCompanyByCompanyID.do",{"truckCompany.id":companyId} ...

  2. Quartz Scheduler misfireThreshold属性的意义与触发器超时后的处理策略

    Quartz misfireThreshold属性的意义与触发器超时后的处理策略. 在配置quartz.properties有这么一个属性就是misfireThreshold,用来指定调度引擎设置触发 ...

  3. VMware vSphere 5.x 与 vSphere 6.0各版本功能特性对比

    各版本中的新特性及功能对比:   VMware vSphere 5.0 VMware vSphere 5.1 VMware vSphere 5.5 VMware vSphere 6.0 ESXi 5. ...

  4. WIFI CAT ET III Adapter Caterpillar ET3 New Arrival

    The old bluetooth cat et adatper iii has stopped production, and you can get the new WIFI CAT Caterp ...

  5. bzoj4361 isn(树状数组优化dp+容斥)

    4361: isn Time Limit: 10 Sec  Memory Limit: 256 MBSubmit: 938  Solved: 485[Submit][Status][Discuss] ...

  6. GuidePage底部导航栏

    import 'package:flutter/material.dart'; import 'News.dart'; import 'Video.dart'; import 'Chat.dart'; ...

  7. Python入门 更换pip源的方法

    pip国内的一些镜像 阿里云 http://mirrors.aliyun.com/pypi/simple/ 中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple ...

  8. esay-ui学习笔记(一)

    JavaScript prototype用法 prototype 属性使您有能力向对象添加属性和方法. object.prototype.name=value <script type=&quo ...

  9. 点击倒计时60S获取验证码

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script sr ...

  10. tomcat的systemctl启动脚本

    最近在做Tomcat的实验,顺便研究了一下tomcat的启动脚本发现一个问题,然后经过多方查阅其他大神的资料,终于解决,现在跟大家分享. tomcat的启动脚本跟别的脚本有稍微区别的原因是他需要识别J ...