1、pom.xml文件中增加如下代码,目的为了下载mybatis、mybatis-spring包
<repositories>
<repository>
<id>mybatis-snapshot</id>
<name>MyBatis Snapshot Repository</name>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</repository>
<repository>
<id>springsource-milestones</id>
<name>SpringSource Milestones Proxy</name>
<url>https://oss.sonatype.org/content/repositories/springsource-milestones</url>
</repository>
</repositories>
2、在log4j.xml中增加如下代码,打印mybatis日志,主要想看sql
<!-- mybatis的日志 -->
<logger name="org.apache.ibatis">
<level value="info" />
</logger>
<logger name="org.ibatis.spring">
<level value="info" />
</logger>
<!-- Root Logger 要打印mybatis,priority设置为debug-->
<root>
<priority value="debug" />
<appender-ref ref="console" />
</root>
3、在web.xml中增加如下代码,解决乱码问题
<!-- 解决乱码 -->
<filter>
<filter-name>CharacterEncodingFilter</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>
</filter>
<filter-mapping>
<filter-name>CharacterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>