How to encrypt the GET request URL in the address bar?

I am using Spring MVC 4.0 in my web application. Here I use the anchor tag to call the controller.

<a href="testDetails?id=3">Details</a> //ie a GET request 

Now I do not want to show this id=3 in my address bar, which is possible with a POST request.

Is there any other way to do this, if possible, using some encryption format, can you provide me some example?

+5
source share
1 answer

I suppose you can use some kind of encryption method for this identifier and then assign it dynamically to your href, however would it be easier to just use the form instead of href to accomplish what you want here? So:

 <form method="post" action="testDetails"> <input type="text" hidden name="id" value="3"/> <input type="submit" value="Send"/> </form> 

This way you can access the POST identifier var "id" to get your value, and it won’t appear in the address bar as you requested.

0
source

Source: https://habr.com/ru/post/1246920/


All Articles