yzt
2023-05-05 953cbbf76091fee9d40045f91c06daee496fe5b3
src/main/resources/spring-mvc.xml
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,55 @@
<?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:mvc="http://www.springframework.org/schema/mvc"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
      http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
      http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
      http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">
    <!-- è‡ªåŠ¨æ‰«æä¸”åªæ‰«æ@Controller -->
    <context:component-scan base-package="com.hxzkoa.controller" use-default-filters="false">
        <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
    </context:component-scan>
   <mvc:annotation-driven>
      <mvc:message-converters register-defaults="true">
         <bean id="jsonConverter" class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter">
            <property name="supportedMediaTypes" value="text/html;charset=UTF-8" />
         </bean>
      </mvc:message-converters>
   </mvc:annotation-driven>
    <aop:aspectj-autoproxy/>
    <!-- å°†æ— æ³•mapping到Controller的path交给default servlet handler处理 -->
    <!-- <mvc:default-servlet-handler/> -->
    <mvc:resources mapping="/static/**" location="/static/"/>
    <!-- å®šä¹‰JSP文件的位置 -->
    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/WEB-INF/"/>
        <property name="suffix" value=".jsp"/>
    </bean>
    <!-- ä¸Šä¼ file-->
    <bean id="multipartResolver"
          class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
          <!--resolveLazily属性启用是为了推迟文件解析,以便在UploadAction ä¸­æ•获文件大小异常-->
        <property name="resolveLazily" value="true"/>
        <!-- one of the properties available; the maximum file size in bytes -->
        <property name="maxUploadSize">
      <!--   æœ€å¤§2M -->
            <value>15728640</value>
            <!-- è®¾ç½®ä¸Šä¼ æ–‡ä»¶å¤§å° -1 ä¸ºä¸é™åˆ¶å¤§å° -->
        </property>
        <property name="maxInMemorySize">
            <value>15728640</value>
        </property>
        <property name="defaultEncoding">
            <value>UTF-8</value>
            <!-- è®¾ç½®ä¸Šä¼ æ—¶çš„编码 -->
        </property>
    </bean>
</beans>