spring 配置注意事项
来源:互联网 发布:java 两个list 去重 编辑:程序博客网 时间:2024/06/07 17:01
1) springmvc的servlet的配置中/和/*有什么区别
/*是拦截了所有的请求,包括视图解析后跳转的.jsp页面,/则不会拦截视图解析后的jsp页面。
2) <mvc:default-servlet-handler />的作用是什么
<mvc:default-servlet-handler />是一个默认的servlet,主要作用去找静态的资源。总结一下就是:
servlet在找页面时,走的是dispatcherServlet路线。找不到的时候会报404
加上这个默认的servlet时候,servlet在找不到的时候会去找静态的内容。
3)SpringMVC interceptor有时候配置的时候path="/**" 两个星号什么意思,与path="/"以及path="/*"什么区别
例如
<mvc:interceptor>
<mvc:mapping path="/**"/>
<bean class="com.web.interceptor.user.UserAuthInterceptor" />
</mvc:interceptor>
/**的意思是所有文件夹及里面的子文件夹
/*是所有文件夹,不含子文件夹
/是web项目的根目录
4)applicationContext.xml和dispatcher-servlet.xml的区别
可见, applicationContext.xml 和 dispatch-servlet.xml形成了两个父子关系的上下文。
1) 一个bean如果在两个文件中都被定义了(比如两个文件中都定义了component scan扫描相同的package), spring会在application context和 servlet context中都生成一个实例,他们处于不同的上下文空间中,他们的行为方式是有可能不一样的。
2) 如果在application context和 servlet context中都存在同一个 @Service 的实例, controller(在servlet context中) 通过 @Resource引用时, 会优先选择servlet context中的实例。
不过最好的方法是:在applicationContext和dispatcher-servlet定义的bean最好不要重复, dispatcher-servlet最好只是定义controller类型的bean。
ApplicationContext.xml 是spring 全局配置文件,用来控制spring 特性的
dispatcher-servlet.xml 是spring mvc里面的,控制器、拦截uri转发view
使用applicationContext.xml文件时是需要在web.xml中添加listener的:
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
5)面向切面编程AOP
这种在运行时,动态地将代码切入到类的指定方法、指定位置上的编程思想就是面向切面的编程。
阅读全文
0 0
- Spring+Hibernate配置注意事项
- spring 配置注意事项
- @Transactional spring 配置事务 注意事项
- spring @Transactional 配置事务 注意事项
- @Transactional spring 配置事务 注意事项
- @Transactional spring 配置事务 注意事项
- @Transactional spring 配置事务 注意事项
- @Transactional spring 配置事务 注意事项
- Spring @Transactional 配置无效 注意事项
- @Transactional spring 配置事务 注意事项
- Java spring项目配置注意事项
- spring boot配置duboo注意事项
- @Transactional spring 配置事务 注意事项
- Spring Bean 配置相关的注意事项
- JTA/XA: Atomikos + Spring + Hibernate 配置 注意事项
- JTA/XA: Atomikos + Spring + Hibernate 配置 注意事项
- @Transactional spring 配置事务 注意事项(转载)
- Spring Aop拦截controller配置注意事项
- 使用C#创建一个计算器
- Android学习笔记四十三之Shape详解
- log4j源码解析
- web过滤器与监听器
- android按键绑定监听器三种方式
- spring 配置注意事项
- Integer Sequences SGU
- Dynamic Coattention Networks For Question Answering
- web设计器--设计流程图(raphael)源码myflow.js(三)
- Android学习笔记四十四之Actionbar和Toolbar
- Java和Scala学习日记7
- 技术就是黄金屋,技术就是颜如玉
- svn版本管理软件——svn发布补丁和打补丁
- extjs regex