I have Query parameter that was encoded by btoa
javascript function. when url clicked, request function called inside java controller where i wanted to decode Query parameter (which is encoded from javascript btoa). i have tried BASE64Decoder
and Base64.getDecoder()
but not able to get proper value. is there any other way to do so?
Java Controller
@RequestMapping(value = "decode/{email}", method = RequestMethod.GET)
public String decodeEmail(Model model, @PathVariable String email){
Decode decode = new Decode();
decode.setEmail(email);
decodeService.save(decode);
return "decode/List";
}
JavaScript
var email = document.getElementById("email").value;
var encodedEmail = btoa(email);
Example
String to encode : demo@demo.com
Encoded String : ZGVtb0BkZW1vLmNvbQ==