問題描述:ant編譯之後(包括java,jsp),總是出現亂碼。
解決之道:
- 在<javac >標籤中寫上encoding=“utf-8”;
<javac encoding="utf-8" destdir="${compile.dir}" includeAntRuntime="no" debug="on" source="1.5" target="1.5" > <src path="${src.java.dir}"/> <patternset refid="compile.sources"/> <classpath> <path refid="compile.dependencies"/> </classpath> </javac>
- 因爲ant會copy,所以copy的時候也要加上encoding=“utf-8”
<!-- Copy resources --> <copy encoding="utf-8" todir="${test.dest.dir}"> <fileset dir="${src.test.dir}" includes="resources/**/*.*"/> </copy>
- 這裏只是介紹ant編譯的中文亂碼問題,涉及到文件的字符編碼集以及jsp頁面上的pageEncoding以及charSet就不在贅述了。