0
点赞
收藏
分享

微信扫一扫

【Azure Function App】Java Function部署到Azure后出现中文显示乱码问题

墨香子儿 2023-07-19 阅读 70

问题描述

Java Function在Azure上遇见中文显示乱码问题?如何解决呢?

 

问题解答

中文字符显示为乱码,这个情况就是服务实例上设置的编码格式不是统一的UTF-8所导致的。

在查看Azure App Service/Function App的官方文档,都没有明确的说明它们使用的默认编码是什么,通过询问ChatGPT-4,也没有得到确定的答案。

【Azure Function App】Java Function部署到Azure后出现中文显示乱码问题_App

但是要解决这个问题,可以设置 Function App的 Application Setting。 添加 JAVA_OPTS ,然后设置值为 -Dfile.encoding=UTF-8

【Azure Function App】Java Function部署到Azure后出现中文显示乱码问题_JAVA_02

注: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>


 

当在复杂的环境中面临问题,格物之道需:浊而静之徐清,安以动之徐生。 云中,恰是如此!

举报

相关推荐

0 条评论