RESTAPI在Java中使用MySQL数据库:与变音符号存储数据问题 [英] RestAPI in Java with MySQL DB: issue on storing data with diacritics

查看:256
本文介绍了RESTAPI在Java中使用MySQL数据库:与变音符号存储数据问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立一个应用程序,我似乎无法处理包含变音符号或其他类型的UTF-8字符的数据。在我来说,我需要的是这个字符的: A-A-A-A-I-I-S-S-T-T

I am building an app and I can't seem to handle the data that contain diacritics or other type of UTF-8 characters. In my case I'm in need of this chars: ă-Ă-â-Â-î-Î-ş-Ş-ţ-Ţ.

现在,首先,有一个收集来自用户的一些信息,经由AngularJS HTTP模块将其发送到API的前端一个输入。标头都好,数据转到API都好。然后,在服务器端,如果我登录的信息,它输出:?????? - - A-A-I-I - - - - ,和当然,同样的信息被放在DB(与phpMyAdmin选中)。

Now, first, there is a input on the front-end that gathers some info from the users, sends it via AngularJS http module to the API. The headers are all good, the data goes to the API all good. Then, on the server side, if I log the info, it outputs: ?-?-â-Â-î-Î-?-?-?-?, and of course, the same info is put in the db (checked with phpmyadmin).

奇怪的是,因为我的应用程序是直接从数据库中的数据打印到我的应用程序,一切顺利的话,它打印,它应该是 A-A-A-A-I- I-S-S-T-T ,直到我重新启动服务器后,它打印,因为它是在数据库中。

The weird thing is, as my app pulls the data from the db to print it to my app, all goes well, it prints as it should be ă-Ă-â-Â-î-Î-ş-Ş-ţ-Ţ, until I restart the server, after which it prints as it is shown in the db.

我要指出,这是不缓存,我测试的无缓存环境的应用程序。我甚至尝试从不同的端点访问只是要确定它是不是从一些地方的问题。

I want to point out that it isn't the cache, I'm testing the app in cache-free environment. I even tried to access from different end-points just to be sure it is not from some local issue.

任何人有什么想法?

推荐答案

我解决了它自己:这个问题是从Java的JPA持久化水平。它没有跨preT的UTF-8对的,因为我给的URL里面。其实我需要做的是建立在GlassFish中的JDBC参数。

I solved it myself: the problem was from JPA persistence level from Java. It didn't interpret the UTF-8 right because I was giving it inside the url. Actually what I needed to do was to create a parameter in glassfish jdbc.

这篇关于RESTAPI在Java中使用MySQL数据库:与变音符号存储数据问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆