ssm整合框架 Spring—MVC基本配置 spring-servlet.xml配置详解

以下为ssm框架整合开发中,对Spring-MVC的配置,文件名为spring-servlet.xml。最下的代码可直接粘贴到spring-servlet.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:p="http://www.springframework.org/schema/p"
    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-3.0.xsd
    http://www.springframework.org/schema/aop
    http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
    http://www.springframework.org/schema/tx
    http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-3.0.xsd
    http://www.springframework.org/schema/mvc
    http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">

    <!-- 启用注解 -->
    <mvc:annotation-driven/>
    <!-- 设置使用注解的类所在的包    必须设置-->
    <context:component-scan base-package="com.wen.ctrl"></context:component-scan>
    <!-- 对转向页面的路径解析。prefix:前缀, suffix:后缀    必须设置 -->
    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver" p:prefix="/" p:suffix=".jsp" />
    <!-- 配置MultipartResolver,用于上传文件,使用spring的CommonsMultipartResolver -->  
    <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
            <!-- 设置上传文件大小,单位byte -->
            <property name="maxUploadSize" value="5000000"/>
            <!-- 设置文件名称编码 -->
            <property name="defaultEncoding" value="UTF-8"/>
    </bean>
  <!-- 对静态资源文件的访问--> 
    <mvc:resources location="/css/" mapping="/css/**" cache-period="31556926"/>
    <mvc:resources location="/images/" mapping="/images/**" cache-period="31556926"/>
    <mvc:resources location="/js/" mapping="/js/**" cache-period="31556926"/>
</beans>

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值