学习了通过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:mvc="http://www.springframework.org/schema/mvc"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/mvc
                        http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
                        http://www.springframework.org/schema/beans
                        http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
                        http://www.springframework.org/schema/context
                          http://www.springframework.org/schema/context/spring-context-3.2.xsd">
    
    <!-- 自动扫描 -->
    <context:component-scan base-package="cn.cfs.springmvc.controller"/>
    <!-- 内部资源视图解析器 prefix + logicName + suffix -->
    <bean name="InternalResourceViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/WEB-INF/jsps/"></property>
        <property name="suffix" value=".jsp"></property>
    </bean>
    <!-- 注解驱动 -->
    <mvc:annotation-driven/>
</beans>
spring-mvc.xml

相关文章:

  • 2022-12-23
  • 2021-06-03
  • 2021-11-06
  • 2021-11-23
  • 2022-12-23
  • 2021-11-28
猜你喜欢
  • 2021-06-14
  • 2022-03-03
  • 2021-06-19
  • 2021-12-25
  • 2021-05-08
  • 2021-11-26
  • 2022-12-23
相关资源
相似解决方案