search
HomeWeb Front-enduni-appHow to solve the problem of garbled characters after uniapp submission

Solution to garbled characters after uniapp is submitted: 1. Encapsulate the value to be transmitted into an object at the front end and pass it to the back end; 2. In the back end, modify the receiving format to "@RequestBody", that is Just receive the json format.

How to solve the problem of garbled characters after uniapp submission

The operating environment of this tutorial: windows7 system, uni-app2.5.1 version, Dell G3 computer.

Recommended (free): uni-app development tutorial

##uni-app front-end get request is passed to the back-end Chinese value garbled problem

Record some garbled code problems encountered when doing final design

1. At the beginning, I used the get method to transfer values ​​to the back-end springboot. It was very friendly when debugging the h5 page. There was no error and everything went smoothly.

How to solve the problem of garbled characters after uniapp submission
How to solve the problem of garbled characters after uniapp submission

2. However, when I open the mobile phone simulator for real-device debugging. . . An accident came:

How to solve the problem of garbled characters after uniapp submission The error message displayed by the name in the background is probably like this. I forgot to cut the picture (my name was entered in Chinese: fruit):

/search/itemname?name="

9x8x9c8b5cv"&page=1&num=12, invalid characters found in the request header

Because the get request occurs in the url request header, so I searched everywhere for solutions to garbled characters, but all I found were decoding in the background.

How to solve the problem of garbled characters after uniapp submission

This did not meet my requirements, because the request header was garbled, and it was simply Didn't enter the program, so it's useless.

After all the trouble, I finally felt that it would be better to use

post to request. So:

3. The front end encapsulates the value to be transmitted into an object and passes it to the back end:

How to solve the problem of garbled characters after uniapp submission It prints out like this:

How to solve the problem of garbled characters after uniapp submission

Send a request in json format to the backend

How to solve the problem of garbled characters after uniapp submission

4. For the backend, change the receiving format to @ RequestBody–that is, the json receiving format (Es7msg is an object I defined and used to receive values)

How to solve the problem of garbled characters after uniapp submission

Then you can successfully get the desired value

How to solve the problem of garbled characters after uniapp submission

I would like to remind everyone that it is best to use post to pass values, which can avoid a lot of garbled characters.

The above is the detailed content of How to solve the problem of garbled characters after uniapp submission. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
VSCode中如何开发uni-app?(教程分享)VSCode中如何开发uni-app?(教程分享)May 13, 2022 pm 08:11 PM

VSCode中如何开发uni-app?下面本篇文章给大家分享一下VSCode中开发uni-app的教程,这可能是最好、最详细的教程了。快来看看!

利用uniapp开发一个简单的地图导航利用uniapp开发一个简单的地图导航Jun 09, 2022 pm 07:46 PM

怎么利用uniapp开发一个简单的地图导航?本篇文章就来为大家提供一个制作简单地图的思路,希望对大家有所帮助!

聊聊如何利用uniapp开发一个贪吃蛇小游戏!聊聊如何利用uniapp开发一个贪吃蛇小游戏!May 20, 2022 pm 07:56 PM

如何利用uniapp开发一个贪吃蛇小游戏?下面本篇文章就手把手带大家在uniapp中实现贪吃蛇小游戏,希望对大家有所帮助!

uni-app vue3接口请求怎么封装uni-app vue3接口请求怎么封装May 11, 2023 pm 07:28 PM

uni-app接口,全局方法封装1.在根目录创建一个api文件,在api文件夹中创建api.js,baseUrl.js和http.js文件2.baseUrl.js文件代码exportdefault"https://XXXX.test03.qcw800.com/api/"3.http.js文件代码exportfunctionhttps(opts,data){lethttpDefaultOpts={url:opts.url,data:data,method:opts.method

手把手带你开发一个uni-app日历插件(并发布)手把手带你开发一个uni-app日历插件(并发布)Jun 30, 2022 pm 08:13 PM

本篇文章手把手带大家开发一个uni-app日历插件,介绍下一款日历插件是如何从开发到发布的,希望对大家有所帮助!

实例讲解uniapp实现多选框的全选功能实例讲解uniapp实现多选框的全选功能Jun 22, 2022 am 11:57 AM

本篇文章给大家带来了关于uniapp的相关知识,其中主要整理了实现多选框的全选功能的相关问题,无法实现全选的原因是动态修改checkbox的checked字段时,界面上的状态能够实时变化,但是无法触发checkbox-group的change事件,下面一起来看一下,希望对大家有帮助。

聊聊uniapp的scroll-view下拉加载聊聊uniapp的scroll-view下拉加载Jul 14, 2022 pm 09:07 PM

uniapp怎么实现scroll-view下拉加载?下面本篇文章聊聊uniapp微信小程序scroll-view的下拉加载,希望对大家有所帮助!

实例详解uniapp如何实现电话录音功能(附代码)实例详解uniapp如何实现电话录音功能(附代码)Jan 05, 2023 pm 04:41 PM

本篇文章给大家带来了关于uniapp的相关知识,其中主要介绍了怎么用uniapp实现拨打电话并且还能同步录音的功能,感兴趣的朋友一起来看一下吧,希望对大家有帮助。

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

Hot Tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)