簡單配置springmvc-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:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="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/aop
http://www.springframework.org/schema/aop/spring-aop-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">

  <!-- 1、配置基於注解的映射器和適配器 -->
  <mvc:annotation-driven/>

  <!-- 處理靜態資源 -->
  <mvc:default-servlet-handler/>
  <!-- <mvc:resources location="/css/" mapping="/css/**"></mvc:resources>
  <mvc:resources location="/vue/" mapping="/vue/**"></mvc:resources>
  <mvc:resources location="/js/" mapping="/js/**"></mvc:resources> -->

  <!-- 2、視圖解析器 -->
  <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="prefix" value="/"></property>
    <!-- <property name="suffix" value=".jsp"></property> -->
  </bean>

  <!-- 3、配置基於上下文進行組件掃描 -->
  <context:component-scan base-package="com.ssm.controller"></context:component-scan>

  <!-- 4、SpringMVC文件上傳規定需配置 MultipartResolver處理器 -->
  <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
    <property name="defaultEncoding" value="UTF-8" />
    <!-- 指定所上傳文件的總大小,單位字節。注意maxUploadSize屬性的限制不是針對單個文件,而是所有文件的容量之和 -->
    <property name="maxUploadSize" value="10485760" />
  </bean>

</beans>


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM