注意事項:
1. Maven中使用Mybatis時,DAO工程下mapper映射文件無法加載到classpath中。
pom.xml中加入如下代碼
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
<include>**/*.properties</include>
</includes>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.xml</include>
<include>**/*.properties</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
</build>
ps:一旦使用這種方式將資源文件加載到classpath下,此時resources目錄下的資源文件不會自動加載到classpath下,故需要以同種方式進行配置。
2. 靜態資源映射
在spring.xml中加入如下代碼
<mvc:resources location="/WEB-INF/js/" mapping="/js/**"/>
<mvc:resources location="/WEB-INF/css/" mapping="/css/**"/>
<mvc:resources location="/WEB-INF/images/" mapping="/images/**"/>
此時,靜態資源文件的放置位置位於/WEB-INF/下。