首页 > 代码库 > maven filter 乱码,MalformedByteSequenceException: Invalid byte 3 of 3-byte UTF-8 sequence.

maven filter 乱码,MalformedByteSequenceException: Invalid byte 3 of 3-byte UTF-8 sequence.

<plugins>	<plugin>		<groupId>org.apache.maven.plugins</groupId>		<artifactId>maven-war-plugin</artifactId>		<version>2.1-beta-1</version>		<configuration>			<warName>admingift</warName>			<webResources>				<resource>					<directory>${basedir}/src/main/webapp/WEB-INF</directory>					<includes>						<include>*.xml</include>						<include>**/*.xml</include>					</includes>					<filtering>true</filtering>					<targetPath>WEB-INF</targetPath>				</resource>				<!-- 本地的jar拷贝到lib下 -->				<resource>					<directory>../lib</directory>					<includes>						<include>*.jar</include>						<include>**/*.jar</include>					</includes>					<targetPath>WEB-INF/lib</targetPath>				</resource>			</webResources>			<webappDirectory>target/admingift</webappDirectory>		</configuration>	</plugin>

上面是我maven的war插件的配置。

被wart filter之后就出现了乱妈,启动报错。MalformedByteSequenceException: Invalid byte 3 of 3-byte UTF-8 sequence.

大概注意的点是:

1、查看被fitler的文件是否带utf-8的Bom头,去掉bom头,带了有可能报错

2、windows  maven的war插件的版本,2.1-bata-1有问题,它的编码识别有问题,怀疑是按照iso-5589-1解析,fitler后的文件16进制查看为3f,造成黑洞现象

3、网上很多解决方式是改成gbk,这个是一种解决方案,如果希望继续使用utf-8编码的,请修改war的filter,还有不要忘记resource插件的编码设置。

maven filter 乱码,MalformedByteSequenceException: Invalid byte 3 of 3-byte UTF-8 sequence.