【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>
 

 

posted @   路边两盏灯  阅读(71)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
历史上的今天:
2022-07-19 【Azure 存储服务】关于Storage Account Queue使用的几个问题
点击右上角即可分享
微信分享提示