【Azure Function App】Java Function部署到Azure后出现中文显示乱码问题
问题描述
Java Function在Azure上遇见中文显示乱码问题?如何解决呢?
问题解答
中文字符显示为乱码,这个情况就是服务实例上设置的编码格式不是统一的UTF-8所导致的。
在查看Azure App Service/Function App的官方文档,都没有明确的说明它们使用的默认编码是什么,通过询问ChatGPT-4,也没有得到确定的答案。
但是要解决这个问题,可以设置 Function App的 Application Setting。 添加 JAVA_OPTS ,然后设置值为 -Dfile.encoding=UTF-8
注:App Service 与 Function App 一样,都是通过添加 JAVA_OPTS 参数来设置编码格式。
参考资料
Configure a Java app for Azure App Service -- Set default character encoding : https://learn.microsoft.com/en-us/azure/app-service/configure-language-java?pivots=platform-windows#set-default-character-encoding
Set default character encoding
In the Azure portal, under Application Settings for the web app, create a new app setting named
JAVA_OPTS
with value-Dfile.encoding=UTF-8
.Alternatively, you can configure the app setting using the App Service Maven plugin. Add the setting name and value tags in the plugin configuration:
<appSettings> <property> <name>JAVA_OPTS</name> <value>-Dfile.encoding=UTF-8</value> </property> </appSettings>
当在复杂的环境中面临问题,格物之道需:浊而静之徐清,安以动之徐生。 云中,恰是如此!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
2022-07-19 【Azure 存储服务】关于Storage Account Queue使用的几个问题