工程原本是maven工程。后来被当做普通web工程在使用。
在启动eclipse的server中时,xml配置文件报编码错误。经过检查后发现工程的xml配置文件编译到classes中时中文出现了乱码。
maven工程,类编译和配置文件输出肯定是到target/classes目录,普通web工程肯定是编译输出到WEB-INF\classes目录,tomcat启动时还是采用的target/classes目录下的编译文件,而恰恰是target/classes下的xml文件编译有问题。
解决方法:
修改.classpath文件中关于编译文件的输出位置(将输出到target/class改成输出到WEB-INF\classes)
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="src" path="src/main/test"/>
<classpathentry kind="src" path="src/main/resources"/>
<classpathentry exported="true" kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/aopalliance-1.0.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/aopalliance.jar"/>
<!-- 其它lib jar配置-->
<classpathentry exported="true" kind="con" path="melibrary.com.genuitec.eclipse.j2eedt.core.MYECLIPSE_JAVAEE_5_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v7.0"/>
<classpathentry kind="output" path="WebContent/WEB-INF/classes"/>
</classpath>
不知道有没有能重新生成.class配置文件的方式。