To solve the problem: SpringMvc forwarding html file Chinese is garbled

@ (SpringMvc set in html parser view it does not work (read extracts relevant content collection of dozens of articles))

1. Environmental instructions, and Preface

Use ssm framework, IDEA, JKD1.8, because this module was written by uploading a template, start first with ajax pass, but I do not know why not injected, can only choose the form, and then jump, so to two pages, and the success of page failure page.

2. Description of the problem:

After a successful jump page html file Chinese garbled, but I have direct access to static resources is not the Chinese garbled, I almost checked dozens of articles, find a number of ways.

3. The method failed (here write failure does not mean not work in other cases)

3.1 html page itself encoding is not UTF-8 (recommended try)

Description : The idea is to html page format was not actually UTF-8, natural access time, is garbled display
solution : use Notepad to open, and then click Save As, set to UTF-8

3.2 web.xml configuration is not provided in the coding mode (the frame configuration must be configured SSM)

 <!-- 配置编码方式-->
  <filter>
    <filter-name>encodingFilter</filter-name>
    <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
    <init-param>
      <param-name>encoding</param-name>
      <param-value>UTF-8</param-value>
    </init-param>
    <init-param>
      <param-name>forceEncoding</param-name>
      <param-value>true</param-value>
    </init-param>
  </filter>
  <filter-mapping>
    <filter-name>encodingFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
  <filter-mapping>
    <filter-name>encodingFilter</filter-name>
    <url-pattern>*.html</url-pattern>
  </filter-mapping>

3.3 modify the html file (with no sense of Cock)

In Baidu, we also found out that this one zh-CN
said it would en changed
for reasons you can see below this article (but this did not help, this explanation is that this is helpful to the search engine)
HTTPS: / /www.w3school.com.cn/tags/html_ref_language_codes.asp

3.4 modify html file < head > (this must be added the html file)

Label added to the head:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

As this code is what does it mean specifically this project can be viewed article
https://www.cnblogs.com/liubeimeng/p/3894177.html
I summed probably meant to say, this meta meta tag html, which contains the corresponding html relevant information, the client browser or server program will be handled according to the information == charset (encoding): this page is encoded UTF-8, should be noted that this is coded web content, rather than the file itself == That set the contents of the file that is encoded as UTF-8 character encoding

3.5 send content to Chinese

For example, you use form form transmitting content, plus you accept-charset = "UTF-8 " sentence code representing
accept-charset attribute specifies the server to process data received form the character set.

    <form action="" method="post" enctype="multipart/form-data" accept-charset="UTF-8">

This represents a form enctype attribute of the form data is sent in the form of what I have here, so to add a sentence file upload, file upload if you do not want this to delete

3.6 JSP translated into coding (configuration of jsp) when Servlet

Use jsp will join this code in the file header, corresponding to the coding when translated JSP Servlet
biggest difference == jsp and a html page is dynamically generated, a static page ==
<% @ Page Language = "java" pageEncoding = "utf- 8"%>

3.7 jsp provided a background coding (jsp write the serverlet is affirmative, an alternative configuration may be such character that the interceptor)

Background can manually set the request character set

request.setCharacterEncoding("UTF-8");

3.8 tomcat's server.xml file to set the encoding format (recommended try)

I find the article said that the way to get
GET submission Chinese garbled resolved
by modifying request.setCharacterEncoding ( "UTF-8") ; coding can only be resolved POST request submitted by way of, for GET invalid.

1, the simplest solution: the solution is no longer any need for additional configuration (e.g., filter)
TOMCAT ISO-8859-1 default can be set to the default encoding UTF-8 solution, the conf \ server.xml file is provided as follows

Java code

<Connector port="8080" protocol="HTTP/1.1"  
                               connectionTimeout="20000"  
                               redirectPort="8443" URIEncoding=”UTF-8”/>  

2, after tomcat4, can be solved by Chinese garbled configuration, but you must configure the filter
settings in conf \ server.xml file as follows

Java code

<Connector port="8080" protocol="HTTP/1.1"  
                                       connectionTimeout="20000"  
                                       redirectPort="8443" useBodyEncodingForURI=“true”  />  

Then request.setCharacterEncoding ( "UTF-8") can also be solved GET garbled
References: https: //www.iteye.com/topic/1121242#2322208

4 problem was solved

The first is the view resolver (I see a lot of the online parser configuration is jsp view of a few days I write about a configuration parser view)
because it is ssm framework, I did not use redirection to jump page, so to view resolver configuration
== view resolver I found online fucked me single-handedly, he only: ==

   <bean id="freemarkerConfig"
        class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
    <property name="templateLoaderPath">
      <value>/WEB-INF/view</value>
    </property>
  </bean>
  <bean id="htmlViewResolver"
        class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
    <property name="contentType" value="text/html;charset=UTF-8"></property>
    <property name="suffix" value=".html"></property>
    <property name="order" value="0"></property>
  </bean>

== == no dynamic local settings

    <property name="freemarkerSettings">
      <props>
        <prop key="locale">zh_CN</prop>
        <prop key="defaultEncoding">UTF-8</prop>
      </props>
    </property>

I tried all of the above methods, and finally succeeded here
to share my view resolver:

     <bean id="freemarkerConfig"
        class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
    <property name="templateLoaderPath">
      <value>/WEB-INF/view</value>
    </property>
    
    <property name="freemarkerSettings">
      <props>
        <prop key="locale">zh_CN</prop>
        <prop key="defaultEncoding">UTF-8</prop>
      </props>
    </property>
    
  </bean>
  <bean id="htmlViewResolver"
        class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
    <property name="contentType" value="text/html;charset=UTF-8"></property>
    <property name="suffix" value=".html"></property>
    <property name="order" value="0"></property>

  </bean>

== also need to import a jar package, maven follows: ==

    <dependency>
      <groupId>org.freemarker</groupId>
      <artifactId>freemarker</artifactId>
      <version>2.3.20</version>
    </dependency>

Also add the following code in web.xml :( if not )

 <filter-mapping>
    <filter-name>encodingFilter</filter-name>
    <url-pattern>*.html</url-pattern>
  </filter-mapping>
  1. What is Freemarker
    FreeMarker is written in the Java language template engine, which is based on a template to generate text output. FreeMarker has nothing to do with the Web container, that is in the Web, it does not know Servlet or HTTP. It not only can be used to achieve technical presentation layer, but also can be used to generate such as XML, JSP or Java.
    Currently the enterprise: the main job of static pages or page impressions with Freemarker

    5. Postscript

    Writing this article I hope to help everyone, today I sat in front of the computer one day just to get this bug, I want to make a small roundabout take the points. What is the problem can communicate with me in the comments area

Share my pom.xml configuration as well as configuration and ssm web.xml configuration:
pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one
  or more contributor license agreements.  See the NOTICE file
  distributed with this work for additional information
  regarding copyright ownership.  The ASF licenses this file
  to you under the Apache License, Version 2.0 (the
  "License"); you may not use this file except in compliance
  with the License.  You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing,
  software distributed under the License is distributed on an
  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  KIND, either express or implied.  See the License for the
  specific language governing permissions and limitations
  under the License.
-->
<!-- $Id: pom.xml 642118 2008-03-28 08:04:16Z reinhard $ -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

  <modelVersion>4.0.0</modelVersion>
  <packaging>war</packaging>

  <name>ITKIMROOT</name>
  <groupId>com.itkim.rootuser</groupId>
  <artifactId>ITKIMROOT</artifactId>
  <version>1.0-SNAPSHOT</version>



  <properties>
    <!-- spring版本号 -->
    <spring.version>4.2.5.RELEASE</spring.version>
    <!-- mybatis版本号 -->
    <mybatis.version>3.2.4</mybatis.version>
    <!-- log4j日志文件管理包版本 -->
    <slf4j.version>1.6.6</slf4j.version>
    <log4j.version>1.2.12</log4j.version>
  </properties>

  <dependencies>
    <!-- spring核心包 -->
    <!-- springframe start -->
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-core</artifactId>
      <version>${spring.version}</version>
    </dependency>

    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-web</artifactId>
      <version>${spring.version}</version>
    </dependency>

    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-oxm</artifactId>
      <version>${spring.version}</version>
    </dependency>

    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-tx</artifactId>
      <version>${spring.version}</version>
    </dependency>

    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-jdbc</artifactId>
      <version>${spring.version}</version>
    </dependency>

    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-webmvc</artifactId>
      <version>${spring.version}</version>
    </dependency>

    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-aop</artifactId>
      <version>${spring.version}</version>
    </dependency>

    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-context-support</artifactId>
      <version>${spring.version}</version>
    </dependency>

    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-test</artifactId>
      <version>${spring.version}</version>
    </dependency>
    <!-- springframe end -->

    <!-- mybatis核心包 -->
    <dependency>
      <groupId>org.mybatis</groupId>
      <artifactId>mybatis</artifactId>
      <version>${mybatis.version}</version>
    </dependency>
    <!-- mybatis/spring包 -->
    <dependency>
      <groupId>org.mybatis</groupId>
      <artifactId>mybatis-spring</artifactId>
      <version>1.2.2</version>
    </dependency>
    <!-- mysql驱动包 -->
    <dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
      <version>8.0.12</version>
    </dependency>
    <!-- junit测试包 -->
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.11</version>
      <scope>test</scope>
    </dependency>
    <!-- jstl -->
    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>jstl</artifactId>
      <version>1.2</version>
    </dependency>
    <dependency>
      <groupId>javax.servlet.jsp</groupId>
      <artifactId>jsp-api</artifactId>
      <version>2.2.1-b03</version>
      <scope>provided</scope>
    </dependency>

    <!-- servlet -->
    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>servlet-api</artifactId>
      <version>2.5</version>
      <scope>provided</scope>
    </dependency>
    <!-- json数据 -->
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-core</artifactId>
      <version>2.7.1</version>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-annotations</artifactId>
      <version>2.7.1</version>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-databind</artifactId>
      <version>2.7.1</version>
    </dependency>
    <dependency>
      <groupId>net.sf.json-lib</groupId>
      <artifactId>json-lib</artifactId>
      <version>2.4</version>
      <classifier>jdk15</classifier>
    </dependency>
    <!-- commons -->
    <dependency>
      <groupId>commons-lang</groupId>
      <artifactId>commons-lang</artifactId>
      <version>2.4</version>
    </dependency>
    <dependency>
      <groupId>commons-logging</groupId>
      <artifactId>commons-logging</artifactId>
      <version>1.1</version>
    </dependency>
    <dependency>
      <groupId>commons-pool</groupId>
      <artifactId>commons-pool</artifactId>
      <version>1.5.6</version>
    </dependency>
    <dependency>
      <groupId>commons-dbcp</groupId>
      <artifactId>commons-dbcp</artifactId>
      <version>1.4</version>
    </dependency>
    <dependency>
      <groupId>commons-beanutils</groupId>
      <artifactId>commons-beanutils</artifactId>
      <version>1.8.3</version>
    </dependency>
    <dependency>
      <groupId>commons-httpclient</groupId>
      <artifactId>commons-httpclient</artifactId>
      <version>3.1</version>
    </dependency>
    <dependency>
      <groupId>commons-collections</groupId>
      <artifactId>commons-collections</artifactId>
      <version>3.1</version>
    </dependency>
    <dependency>
      <groupId>commons-codec</groupId>
      <artifactId>commons-codec</artifactId>
      <version>1.9</version>
    </dependency>
    <dependency>
      <groupId>javax.annotation</groupId>
      <artifactId>jsr250-api</artifactId>
      <version>1.0</version>
    </dependency>

    <dependency>
      <groupId>net.sf.ezmorph</groupId>
      <artifactId>ezmorph</artifactId>
      <version>1.0.6</version>
    </dependency>
    <dependency>
      <groupId>javax.activation</groupId>
      <artifactId>activation</artifactId>
      <version>1.1</version>
    </dependency>
    <dependency>
      <groupId>taglibs</groupId>
      <artifactId>standard</artifactId>
      <version>1.1.2</version>
    </dependency>
    <!-- 日志文件管理包 -->
    <!-- log start -->
    <dependency>
      <groupId>log4j</groupId>
      <artifactId>log4j</artifactId>
      <version>${log4j.version}</version>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <version>${slf4j.version}</version>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-log4j12</artifactId>
      <version>${slf4j.version}</version>
    </dependency>
    <!--上传-->
    <dependency>
      <groupId>commons-fileupload</groupId>
      <artifactId>commons-fileupload</artifactId>
      <version>1.3.1</version>
    </dependency>
    <dependency>
      <groupId>commons-io</groupId>
      <artifactId>commons-io</artifactId>
      <version>2.4</version>
    </dependency>
    <dependency>
      <groupId>org.freemarker</groupId>
      <artifactId>freemarker</artifactId>
      <version>2.3.20</version>
    </dependency>
    <!-- log end -->
  </dependencies>
  <build>

    <finalName>helloworld</finalName>
    <plugins>
      <plugin>
        <groupId>org.mybatis.generator</groupId>
        <artifactId>mybatis-generator-maven-plugin</artifactId>
        <version>1.3.2</version>
        <configuration>
          <!--允许移动生成的文件-->
          <verbose>true</verbose>
          <!--允许覆盖生成的文件-->
          <overwrite>true</overwrite>
        </configuration>
      </plugin>
    </plugins>
    <resources>
      <resource>
        <directory>src/main/java</directory>
        <includes>
          <include>**/*.properties</include>
          <include>**/*.xml</include>
        </includes>
        <filtering>false</filtering>
      </resource>
      <resource>
        <directory>src/main/resources</directory>
        <includes>
          <include>**/*.properties</include>
          <include>**/*.xml</include>
        </includes>
        <filtering>false</filtering>
      </resource>
    </resources>
  </build>
</project>

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
  <display-name>helloworld</display-name>
  <!-- 配置编码方式-->
  <filter>
    <filter-name>encodingFilter</filter-name>
    <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
    <init-param>
      <param-name>encoding</param-name>
      <param-value>UTF-8</param-value>
    </init-param>
    <init-param>
      <param-name>forceEncoding</param-name>
      <param-value>true</param-value>
    </init-param>
  </filter>
  <filter-mapping>
    <filter-name>encodingFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
  <filter-mapping>
    <filter-name>encodingFilter</filter-name>
    <url-pattern>*.html</url-pattern>
  </filter-mapping>



  <!-- 配置springmvc的前端控制器 指向spring-mvc.xml 程序在启动的时候就加载springmvc 可以接受所有请求 load-on-startup:表示启动容器时初始化该Servlet; -->
  <servlet>
    <servlet-name>springServlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <!-- 可以自定义servlet.xml配置文件的位置和名称, 默认为WEB-INF目录下,名称为[<servlet-name>]-servlet.xml,如spring-servlet.xml -->
    <init-param>
      <param-name>contextConfigLocation</param-name>
      <param-value> classpath:/applicationContext.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <!-- 将前端URL请求和后台处理方法controller建立对应关系-->
  <servlet-mapping>
    <servlet-name>springServlet</servlet-name>
    <url-pattern>/</url-pattern>
  </servlet-mapping>

  <!-- Spring配置 -->
  <listener>
    <listener-class>
      org.springframework.web.context.ContextLoaderListener
    </listener-class>
  </listener>
  <!-- 取消对某一类文件的拦截-->
  <servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>*.md</url-pattern>
  </servlet-mapping>

  <servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>*.html</url-pattern>
  </servlet-mapping>

  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value> classpath:/applicationContext.xml</param-value>
  </context-param>
  <!-- 欢迎页面-->
  <welcome-file-list>
    <welcome-file>/index.html</welcome-file>
  </welcome-file-list>
  <!--404错误展示页面,可自行配置-->
  <!--<error-page>-->
  <!--<error-code>404</error-code>-->
  <!--<location>/WEB-INF/views/404.jsp</location>-->
  <!--</error-page>-->
  <!--设置session失效时间为30分钟 -->
  <session-config>
    <session-timeout>600</session-timeout>
  </session-config>
</web-app>
       

springmvc settings applicationContext.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:beans="http://www.springframework.org/schema/beans"
       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.3.xsd
         http://www.springframework.org/schema/context
         http://www.springframework.org/schema/context/spring-context-4.3.xsd
         http://www.springframework.org/schema/mvc
         http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd"  >


  <!-- ①:对com.springmvc包中的所有类进行扫描,以完成Bean创建和自动依赖注入的功能 -->
  <context:component-scan base-package="com.darksouls"/>

  <mvc:annotation-driven />
  <!-- 静态资源访问 -->
  <!--如果webapp下你新建了文件夹,想访问里面的静态资源,那么就要在这配置一下-->
  <mvc:resources location="/images/" mapping="/images/**"/>
  <mvc:resources location="/css/" mapping="/css/**"/>
  <mvc:resources location="/js/" mapping="/js/**"/>
  <mvc:resources location="/WEB-INF/view/" mapping="/**.html" />






  <!-- Configures the @Controller programming model
  <mvc:annotation-driven />-->
  <!-- ②:启动Spring MVC的注解功能,完成请求和注解POJO的映射 -->
  <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
    <property name="messageConverters">
      <list>
        <ref bean="mappingJacksonHttpMessageConverter"/>
      </list>
    </property>
  </bean>

  <bean id="mappingJacksonHttpMessageConverter" class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
    <property name="supportedMediaTypes">
      <list>
        <value>application/json;charset=UTF-8</value>
      </list>
    </property>
  </bean>





  <!-- 配置视图解析器,把控制器的逻辑视频映射为真正的视图 -->
  <!-- /WEB-INF/jsp/start.jsp -->
  <!--<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">-->
    <!--<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>-->
    <!--<property name="prefix" value="/WEB-INF/views/" />-->
    <!--<property name="suffix" value=".jsp" />-->
  <!--</bean>-->
  <bean id="freemarkerConfig"
        class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
    <property name="templateLoaderPath">
      <value>/WEB-INF/view</value>
    </property>

    <property name="freemarkerSettings">
      <props>
        <prop key="locale">zh_CN</prop>
        <prop key="defaultEncoding">UTF-8</prop>
      </props>
    </property>

  </bean>
  <bean id="htmlViewResolver"
        class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
    <property name="contentType" value="text/html;charset=UTF-8"></property>
    <property name="suffix" value=".html"></property>
    <property name="order" value="0"></property>

  </bean>





  <!-- 配置dbcp数据库连接池 -->

  <!-- <context:property-placeholder location="classpath:db.properties"/> -->
  <!--数据库配置 -->
  <bean id = "propertyConfigurer" class = "org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="locations">
      <list>
        <value>classpath:jdbc.properties</value>
      </list>
    </property>

  </bean>

  <!-- 数据库连接池 -->
  <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    <property name="driverClassName" value="${driver}"/>
    <property name="url" value="${url}"/>
    <property name="username" value="${username}"/>
    <property name="password" value="${password}"/>
    <property name="initialSize" value="1"/>
    <property name="maxActive" value="100"/>
    <property name="maxIdle" value="5"/>
    <property name="maxWait" value="80000"/>
  </bean>

  <!-- 配置事务管理器 -->
  <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    <property name="dataSource" ref="dataSource" />
  </bean>

  <!-- 拦截器 -->
  <mvc:interceptors>
    <!-- 国际化操作拦截器 如果采用基于(请求/Session/Cookie)则必需配置 -->
    <bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor" />
  </mvc:interceptors>
  <!-- 定义无Controller的path<->view直接映射 -->
  <!-- <mvc:view-controller path="/" view-name="redirect:/" /> -->

  <!-- 配置会话工厂SqlSessionFactory -->

  <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
    <!-- 数据源 -->
    <property name="dataSource" ref="dataSource"/>
    <property name="mapperLocations" value="classpath:sqlmap/*.xml"/>
    <property name="typeAliasesPackage" value="com.darksouls.entity" />
  </bean>

  <!-- 在spring容器中配置mapper的扫描器产生的动态代理对象在spring的容器中自动注册,bean的id就是mapper类名(首字母小写)-->
  <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
    <!-- 指定扫描包的路径,就是mapper接口的路径,多个包中间以 半角逗号隔开   -->
    <property name="basePackage" value="com.darksouls.dao"/>
    <!-- 配置sqlSessionFactoryBeanName -->
    <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
  </bean>
  <!--文件解析器-->
  <bean id="multipartResolver"
        class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
    <property name="maxUploadSize">
      <value>5242880</value>
    </property>
  </bean>

</beans>

Guess you like

Origin www.cnblogs.com/lzy321/p/11487770.html
Recommended