在前端输入之后,数据发到后台就会后乱码的出现,其实就是网页的输入编码是ISO_8859_1而我们java后端是utf-8
name = new String(name.getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8);
System.out.println(name);
在前端输入的数据以ISO_8859_1编码发送至UTF-8配置的Java后端时出现了乱码。为解决此问题,可以将接收到的ISO_8859_1编码的数据转换为UTF-8,如`name=newString(name.getBytes(StandardCharsets.ISO_8859_1),StandardCharsets.UTF_8);`此代码片段演示了转换过程。
在前端输入之后,数据发到后台就会后乱码的出现,其实就是网页的输入编码是ISO_8859_1而我们java后端是utf-8
name = new String(name.getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8);
System.out.println(name);
1382

被折叠的 条评论
为什么被折叠?