Sunday 15 February 2015

controller - Url Routing with Encoding in Java Web API -


I am new to Java and I am trying to write a utility API to encrypt / decrypt a string. I have my controller and request mapping, and I'm working in encrypt / decrypt mode.

The problem I have is decrypting a string in which there is a forward slash ('/'). If I leave unencoded in the URL (like http: // localhost: 8080 / api / package / util / decrypt / oJfTtchpM9WC / 4Oqpu7FZQ == ) then url routing breaks (which is clear why).

If I change the URL to symbolic words (such as http: // localhost: 8080 / api / package / util / decrypt / oJfTtchpM9WC% 2F4Oqpu7FZQ == ) then the values ​​in the path The variable is empty

Also keep in mind that http :. // localhost:. 8080 / api / package / util / decrypt / oJfTtchpM9WC (no slash) works fine

It seems that whenever I put '%' in the path variable, I get feedback Finds an empty page in I do not hit the method

I have simplified my decrypt method to output only the path variable, which is data < Pre> @RequestMapping (value = "/ util / decrypt / {data}", method = RequestMethod.GET) @ResponseBody public string decrypt (HttpServletResponse HttpResponse, @PathVariable string data) throws exceptions {return data; // return URLDecoder.decode (data, "UTF-8"); }

Can anyone explain to me what is happening and how can I work it out?

Many thanks !!

I have updated my encrypt method to use the function (vs just sign breaks versus 64 string) and also changed it to pass the data as a standard request param (I.e.? Data = string). This problem has been removed.

The base 64 algorithm encodes the binary data using the URL-secured variation, but does not share the output. Emergence of url-secured variance - and instead of + and / character / note: no padding is added.

No comments:

Post a Comment