I am trying to pass a search string near the javascript front-end that is reaching another API is.
With all the special characters leaving the string "string + 123" was running.
I have used encoding / decoding to solve this bug by using the combination of JavaScript encodeurIComponent () (), and Java URLDecoder ()
In addition to this I saw this:
They "utf8" (UrlDecoder.decode (string, "Utf8");)
I just changed javascript encode only , which pulls a string of correct result to my string "test + 123".
My logger indicates that the search is being searched on the right string.
Ex "test + 123": without encoding javascript -> "test 123"
with javascript encoding -> "test + 123"
Java decode With -> No results?
My JavaScript code looks like this:
var encodedString = encodeURIComponent ($ ("#search-input") ().);
My Java code looks like this:
string result = URLDecoder.decode (encoded searchstring, "UTF8");
I checked the debugger and my logger is correct, the encoded searchstring is not encoded.
What's going on?
I have not written any other code related to encoding or decoding, I do not think the code is going to happen elsewhere. I am using spring mvc, maven, and intellj if this is the case
Maybe the syntax should be UTF-8 instead of utf8?
string result = URLDecoder.decode (encoded search string, "UTF-8");
No comments:
Post a Comment