spring 框架的配置文件
来源:互联网 发布:java wait 例子 编辑:程序博客网 时间:2024/05/29 08:07
首先要导入需要的jar包
配置web.xml:
<!-- Spring MVC配置 --><!-- ====================================== --><servlet> <servlet-name>spring</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <!-- 可以自定义servlet.xml配置文件的位置和名称,默认为WEB-INF目录下,名称为[<servlet-name>]-servlet.xml,如spring-servlet.xml <init-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/spring-servlet.xml</param-value> 默认 </init-param> --> <load-on-startup>1</load-on-startup></servlet><servlet-mapping> <servlet-name>spring</servlet-name> <url-pattern>*.jsp</url-pattern>
<!-- <url-pattern>/</url-pattern> --></servlet-mapping><!-- Spring配置 --><!-- ====================================== -->
<listener> <listenerclass> org.springframework.web.context.ContextLoaderListener </listener-class></listener> <!-- 指定Spring Bean的配置文件所在目录。默认配置在WEB-INF目录下 --><context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:config/applicationContext.xml</param-value></context-param>
配置spring-servlet.xml(spring-servlet这个名字是因为上面web.xml中<servlet-name>标签配的值为spring(<servlet-name>spring</servlet-name>),再加上“-servlet”后缀而形成的spring-servlet.xml文件名,如果改为springMVC,对应的文件名则为springMVC-servlet.xml):
<?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-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/context <a href="http://www.springframework.org/schema/context/spring-context-3.0.xsd">http://www.springframework.org/schema/context/spring-context-3.0.xsd</a>"> <!-- 启用spring mvc 注解 --> <context:annotation-config /> <!-- 设置使用注解的类所在的jar包 --> <context:component-scan base-package="controller"></context:component-scan> <!-- 完成请求和注解POJO的映射 --> <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" /> <!-- 对转向页面的路径解析。prefix:前缀, suffix:后缀 --> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver" p:prefix="/jsp/" p:suffix=".jsp" /></beans>
0 0
- spring 框架的配置文件
- spring 框架配置文件详解
- Spring框架中如何读取Spring的XML配置文件
- SSH之 spring框架配置文件
- Spring框架配置文件:applicationContext.xml
- spring框架读取配置文件信息
- Struts2+Spring, 将框架的配置文件整合起来
- SSH框架联合开发(Annotation精简Spring的配置文件)
- SSH框架联合开发(Annotation精简Spring的配置文件)
- Spring+Struts2, 将框架的配置文件整合起来
- 基于注解的ssh框架之spring配置文件
- Spring框架--实现使用配置文件控制对象的生成
- spring框架自带的bean配置文件模板-beanConfigurerTests.xml
- 浅谈spring+springMVC+mybatis框架整合(配置文件的使用)
- Spring ,Springmvc,mybatis三大框架整合的配置文件支持
- spring框架访问properties配置文件的设置方法
- Spring-Spring框架基本配置文件解析
- SSM框架的配置文件
- 分页,搜索后保留搜索条件分页
- 如何有效的做Code Review
- HBase shell查询
- Linux并发控制
- FragmentActivity与Fragment两者交互方法简介
- spring 框架的配置文件
- docker-composede 的使用
- SharedPreferences——安卓存储方案之一
- 使用FLASHBACK TABLE 恢复被删除表
- nova修改libvirt.xml及自定义xml文件修改nova代码支持vhost
- HBase拆分策略
- 微信红包接口---你不知道的坑爹官方支付文档
- RecyclerView的使用方法和瀑布流的实现
- Android 实现图片高斯模糊算法,真正有效的工具类