springmvc-xml的配置文件
# 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:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
https://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tool
http://www.springframework.org/schema/tool/spring-tool.xsd
http://www.springframework.org/schema/mvc
https://www.springframework.org/schema/mvc/spring-mvc.xsd">
<!--1、注解的支持-->
<context:annotation-config></context:annotation-config>
<!--2、设置组件的扫描路径-->
<context:component-scan base-package="com.singerw"></context:component-scan>
<!--3、检查springmvc配置文件中加入: <mvc:annotation-driven>
如果没有加入mvc-annotation的节点,可能会出现如下错误:-->
<!--自动开启处理器映射器-->
<!--自动开启处理器适配器-->
<mvc:annotation-driven></mvc:annotation-driven>
<!--4、配置视图解析器-->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/blog/"/>
<property name="suffix" value=".html"/>
</bean>
<!--5、让SpringMVC不处理静态资源的处理,注意,请求还是有走前端控制器,只不过不处理 -->
<mvc:default-servlet-handler></mvc:default-servlet-handler>
</beans>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
编辑 (opens new window)