您当前的位置: 首页 > 慢生活 > 程序人生 网站首页程序人生
4-ssm整合-原始整合方式spring和mvc配置文件内容填充
发布时间:2025-02-08 12:47:45编辑:雪饮阅读()
-
接续上篇,这次来配置applicationContext.xml,则如D:\os\SpringWebApp\SpringProject2Module10SSM\src\main\resources\applicationContext.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:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<!--组件扫描 扫描service和mapper-->
<context:component-scan base-package="sp10">
<!--排除controller-->
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
</beans>
接下来配置spring-mvc.xml,
主要配置controller控制器的组件扫描,mvc注解驱动,内部资源视图解析器,开放静态资源访问权限
如D:\os\SpringWebApp\SpringProject2Module10SSM\src\main\resources\spring-mvc.xml:
<?xml version="1.0" encoding="UTF-8" ?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<!--组件扫描 主要扫描controller-->
<context:component-scan base-package="sp10.controller"/>
<!--配置mvc注解驱动-->
<mvc:annotation-driven/>
<!--内部资源视图解析器-->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/pages/"/>
<property name="suffix" value=".jsp"/>
</bean>
<!--开放静态资源访问权限-->
<mvc:default-servlet-handler/>
</beans>
关键字词:ssm,原始,方式,环境,搭建,整合,填充,spring,mvc