eclipse html 文件编码格式错误导致乱码的分析及解决

本文介绍在使用STS加载Maven项目时遇到的HTML文件中文乱码问题,详细阐述了如何将项目中所有HTML文件的编码格式统一设置为UTF-8,以确保中文字符正确显示。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、使用STS(Spring 定制的eclipse)加载一个maven 项目。

2、设置项目的编码格式为UTF-8

3、问题出现了,java 代码都没有问题,发现html文件中文乱码。通过文件的属性查看,文件格式为GBK格式。(没有搞清楚为什么~~~)

4、通过设置文件的编码类型为UTF-8,中文可以正常显示。

5、但项目中有很多html文件,不能一个一个的单独设置,怎么办?

The General > Content Types preference page enables you to edit content types and their associated file names, editors and character sets. You can also associate arbitrary file names or file extensions with content types. A content type acts as a description of a certain class of files (for instance, XML files). Eclipse uses this description in various scenarios, such as editor look-ups and file comparisons.

To access the Content Types preference page, select Window > Preferences > General > Content Types.

设置后再次打开文件,发现所有的编码格式都变成UTF-8了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值