首先做好环境配置


在mvc.xml里进行配置

  1.开启组件扫描

  2.开启基于mvc的标注

  3.配置试图处理器

 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <beans xmlns="http://www.springframework.org/schema/beans"
 3     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 4     xmlns:context="http://www.springframework.org/schema/context"
 5     xmlns:lang="http://www.springframework.org/schema/lang"
 6     xmlns:mvc="http://www.springframework.org/schema/mvc"
 7     xmlns:util="http://www.springframework.org/schema/util"
 8     xmlns:task="http://www.springframework.org/schema/task"
 9     xmlns:aop="http://www.springframework.org/schema/aop"
10     xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd
11         http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-4.1.xsd
12         http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
13         http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd
14         http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-4.1.xsd
15         http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.1.xsd
16         http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.1.xsd">
17     <!-- 开启组件扫描 -->
18     <context:component-scan base-package="com.xcz"></context:component-scan>
19     <!-- 开启mvc标注 -->
20     <mvc:annotation-driven></mvc:annotation-driven>
21     <!-- 配置视图处理器 -->
22     <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
23         <property name="prefix" value="/WEB-INF/"></property>
24         <property name="suffix" value=".jsp"></property>
25     </bean>
26 </beans>
mvc.xml

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-06
  • 2021-12-16
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-06-30
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-25
相关资源
相似解决方案