Hello to the community I commented that I am using angular 1.6, and I am sending a json with special characters (ñ, é), but when checking in the controller I get distorted.
service - angular
var json_ins = { ... } ; // special characters
var data = encodeURIComponent(JSON.stringify(json_ins));
$http.get(VAR_CONTEXT+'/team/update?data=' + data).then(
function (response) {
deferred.resolve(response);
},
function (errResponse) {
console.error('Error: Service Users');
deferred.reject(errResponse);
}
);
RestController
@RequestMapping(value = "/team/update", method = RequestMethod.GET)
public String update(HttpServletRequest request, HttpServletResponse response, @QueryParam("data") String data) {
Gson gson = new Gson();
JsonParser jsonParser = new JsonParser();
JsonObject jResponse = new JsonObject();
boolean success = true;
try {
Type detInscripcionType = new TypeToken<DetInscripcion>() {}.getType();
DetInscripcion detInscripcion = new Gson().fromJson(data, detInscripcionType);
IntegranteBean integranteBean = inscripcionService.updateDetInscripcion(detInscripcion);
JsonObject jsonObject = (JsonObject) jsonParser.parse(gson.toJson(integranteBean));
jResponse.add("data", jsonObject);
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
success = false;
jResponse.addProperty("message", "Error de Conexion.");
}
jResponse.addProperty("success", success);
return new Gson().toJson(jResponse);
}
I hope you can help me, since by checking the variable data, the special character comes to me distorted.