springMVC的配置文件路径问题
①
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</init-param>
路径:1,src目录下 2,src\main\resources目录下
②不使用classpath
<param-value>/WEB-INF/applicationContext.xml</param-value>
③不写<init-param>时
<servlet>
<servlet-name>dispatch</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
</servlet>
默认为xxx-servlet.xml,默认路径为/WEN-INF/xxx-servlet.xml(XXX为servlet-name即是:dispatch)
即是:dispatch-servlet.xml
另:url路径问题
举例1:
- @Controller
- @RequestMapping("/welcome")
- public class HelloWorldController {
- @RequestMapping(value="/hello" ,method=RequestMethod.GET)
- public String printWelcome(ModelMap model){
- model.addAttribute("message" ,"Spring 3 MVC Hello World");
- return "hello"; }
- }
- url:http://localhost:8080/demo1/welcome/hello
举例2:
- @Controller
- public class HomeController {
- @RequestMapping("home")
- public String home(){
- return "home"; }
- }
- url:http://localhost:8080/demo1/home
web.xml
- </servlet>
- <servlet-mapping>
- <servlet-name>dispatch</servlet-name>
- <url-pattern>/</url-pattern>
- </servlet-mapping>
application.xml
- <context:component-scan base-package="com.vito.action" />
- <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
- <property name="prefix" value="/WEB-INF/jsp/" />
- <property name="suffix" value=".jsp" />
- </bean>
springMVC的配置文件路径问题的更多相关文章
- 3.SpringMVC修改配置文件路径和给界面传递数据
1.修改配置文件路径 达到 配置多文件的目的 web.xml文件中基础配置有springMVC配置的servlet路径 <servlet-name>SpringMVC</serv ...
- (转)SpringMVC学习(三)——SpringMVC的配置文件
http://blog.csdn.net/yerenyuan_pku/article/details/72231527 读者阅读过SpringMVC学习(一)——SpringMVC介绍与入门这篇文章后 ...
- springMVC访问根路径问题
当web.xml没有配置欢迎页:如下 <welcome-file-list> <welcome-file>login.jsp</welcome-file> < ...
- Spring+SpringMVC整合----配置文件
1.在 web.xml 中加载 spring 的配置文件 bean.xml 底层是 Listener <!-- Spring --> <context-param> &l ...
- springMVC项目配置文件
一.springMVC项目配置文件 1.web.xml文件全局配置 <servlet> <servlet-name> dispatcher </servlet-name& ...
- 查看nginx配置文件路径
进入nginx安装目录(我的是/usr/local/nginx-1.7.8/) 进入sbin目录,输入 ./nginx -t查看nginx配置文件路径以及该文件语法是否正确 ./nginx -v查看n ...
- thinkphp配置文件路径
thinkphp配置文件路径在入口文件index.php中配置. 如果Public目录在应用程序目录同等级位置: 2.如果Public在app内部则: 3.如果使用Public在app外部,但定义为: ...
- c# 根据配置文件路径,设置和获取config文件 appSettings 节点值
/// <summary> /// 获取编译后的主配置文件节点值 /// </summary> /// <param name="key">&l ...
- 关于springmvc的配置文件
开发常用的springmvc.xml配置文件,spring 3.0 spring-servlet.xml配置. <?xml version="1.0" encoding=&q ...
随机推荐
- [LeetCode] Power of Two 判断2的次方数
Given an integer, write a function to determine if it is a power of two. Hint: Could you solve it in ...
- SqlServer按中文数字排序
表数据: 按名称排序 并不能得到一二三四五六的顺序 select * from LiWei order by name 找到中文数字在'一二三四五六七八九十'的位置 select id,name,SU ...
- .NET WebAPI 用ActionFilterAttribute实现token令牌验证与对Action的权限控制
项目背景是一个社区类的APP(求轻吐...),博主主要负责后台业务及接口.以前没玩过webAPI,但是领导要求必须用这个(具体原因鬼知道),只好硬着头皮上了. 最近刚做完权限这一块,分享出来给大家.欢 ...
- JavaScript 属性类型(数据属性和访问器属性)
数据属性 数据属性包含一个数据值的位置.在这个位置可以读取和写入值.数据属性有 4 个描述其行为的特性. [[Configurable]]:表示能否通过 delete 删除属性从而重新定义属性,能否修 ...
- linux基础-磁盘阵列(RAID)实例详解
磁盘阵列(RAID)实例详解 raid技术分类 软raid技术 硬raid技术 Raid和lvm的区别 为什么选择用raid RAID详解 RAID-0 RAID-1 RAID-5 Raid-10 R ...
- js中的原型prototype
var arr1 = new Array(12,34,98,43,38,79,56,1); arr1.sum=function (){ var result = 0; for(var i=0; i&l ...
- lua命令行编译
http://jingyan.baidu.com/article/359911f551917457fe0306e5.html 最后将生成的.exe解释器的根目录配置到系统环境变量 copy lua.c ...
- csv to splite db form
termsql: https://github.com/tobimensch/termsql termsql -i textfile -d ',' -o sqlite.db 添加列名 termsql ...
- 企业站SEO记录
半个多月前给接了一个企业站,赚点小钱,客户也没什么要求,所以就找了模板修改了一下就上线了,然后又做了微信网站.搭了微信公众号,也都没什么技术含量,最伤脑筋的就是做关键词排名了,虽然做的几个词竞争也不是 ...
- Mac下maven工程的创建,并搭建SSH环境
最近项目有用到maven,就特地学了一下.maven的一句话攻略就是,项目托管.帮你解决各种项目琐事:清理,导包....等等. 首先先到apach官网去下载一个maven的包,http://maven ...