3.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:mvc="http://www.springframework.org/schema/mvc"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/context
    https://www.springframework.org/schema/context/spring-context.xsd
    http://www.springframework.org/schema/mvc
    https://www.springframework.org/schema/mvc/spring-mvc.xsd">
<!-- Spring MVC不处理静态资源 -->
  <mvc:default-servlet-handler />
<!-- springmvc自带的注解生效 -->
  <mvc:annotation-driven >
    <mvc:message-converters>
    <bean id="fastjson" class="com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter">
 
      <property name="supportedMediaTypes">
      <list>
        <value>text/html;charset=UTF-8</value>
        <value>application/json;charset=UTF-8</value>
      </list>
      </property>
    </bean>
  </mvc:message-converters>
 </mvc:annotation-driven>
<!--文件上传配置-->
    <bean id="multipartResolver"
    class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<!-- 请求的编码格式,必须和jSPpageEncoding属性一致,以便正确读取表单的内容,默认为ISO-8859-1 -->
    <property name="defaultEncoding" value="utf-8"/>
<!-- 上传文件大小上限,单位为字节(10485760=10M-->
    <property name="maxUploadSize" value="10485760"/>
    <property name="maxInMemorySize" value="40960"/>
    </bean>
<!-- 处理映射器 -->
  <bean class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping"/>
<!-- 处理器适配器 -->

  <bean class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter"/>
<!--视图解析器:DispatcherServlet给他的ModelAndView-->
  <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"
    id="InternalResourceViewResolver">
  <!--前缀-->
    <property name="prefix" value="/WEB-INF/page/"/>
  <!--后缀-->
    <property name="suffix" value=".jsp"/>
  </bean>
</beans>

 

posted @ 2021-05-02 17:52  小小书童9527  阅读(245)  评论(0编辑  收藏  举报