SpringMvc配置文件注意事项

来源:互联网 发布:vim c语言插件 编辑:程序博客网 时间:2024/05/22 12:09
<?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:aop="http://www.springframework.org/schema/aop"   
    xmlns:context="http://www.springframework.org/schema/context"  
    xmlns:jee="http://www.springframework.org/schema/jee"  
    xmlns:tx="http://www.springframework.org/schema/tx"  
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xsi:schemaLocation="    
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.2.xsd  
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd  
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd  
        http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.2.xsd  
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.2.xsd
        http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd
        ">

    <!-- 扫描包(Controller|Service|Repository|Autowired|Component|Resource|...) -->
    <context:component-scan base-package="com.wskj.spring"></context:component-scan>

    <!-- 启用注解 -->
    <mvc:annotation-driven></mvc:annotation-driven>

    
    <mvc:resources location="/resource/" mapping="/static/**"></mvc:resources>
    
    <!-- 文件上传解析器 -->
    <bean id="multipartResolver"
        class="org.springframework.web.multipart.commons.CommonsMultipartResolver"
        p:maxUploadSize="34564356"
        p:defaultEncoding="utf-8">
        <!-- <property name="defaultEncoding" value="utf-8"></property> -->
    </bean>
    
    <!-- 视图解析器 -->
    <bean id="internalResourceViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <!-- 前缀 -->
        <property name="prefix" value="/WEB-INF/pages/" />
        <!-- 后缀 -->
        <property name="suffix" value=".jsp" />
    </bean>

    </beans>



对于springMvc 必须手动启动注解!默认是使用BeanNameUrlHandlerMapping方式


0 0
原创粉丝点击