Spring Framework - Difference Between GET and POST

I am developing a web page in JSP using Spring Framework, I know the difference between GET and POST in general if the page is sent with a POST action; the information sent is not displayed in the browser area, and in GET it is just the opposite.

In Spring framework I send and receive information through controllers and just before writing my controller, I use request mapping like:

@RequestMapping(value = "/pri/SuperUser/ResetPassword.qib",method = RequestMethod.GET)
@Override
public ModelandView function(Model model){
...
...

      

So what is the difference between using GET and POST in this case. There must be something other than just viewing the submitted information in a browser field.

0


source to share


5 answers


It looks like you haven't quite understood GET / POST yet.

Try to think of it this way for a web application:

GET The GET method should be used to retrieve data from the server. Multiple requests to get the same URL must be valid and the data must not be changed on the server side.

However, this does not mean that it is impossible to make the GET request modified on the server side, but you should try to make sure that you follow the standard.

POST The POST method should be used when you need to create, update or delete data on the server side. Making the same POST request multiple times can be unsafe and can result in inconsistent data. The content of the POST request is sent to the body of the request. Hence, you don't see the options in your browser, but it's easy to see them if you want to (even using the browser developer tools), so it's no more secure than a GET request.



NOTE: this is how they are used in general on the WEB, this is not an actual specification as there are other methods available. If you are creating a REST service, you will want to explore other methods.

(Briefly - POST - to create data, PUT - to update data and DELETE to delete data)

It might be worth reading the actual spec to get a complete understanding: http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html

If you want to secure your HTTP requests, this can be done using SSL encryption over HTTPS (separate topic)

+17


source


GET is secure, idempotent and cacheable

POST - none of these characteristics



Check out: GoogleDevelopers Link (video)

+1


source


This is the same as in general. The process RequestMapping

sends GET or POST data.

eg. if you typed in your browser "DOMAIN / pri / SuperUser / ResetPassword.qib" and open the url it GET.

If you submit a form with a POST method from an HTML page, it is submitted

0


source


The method will only accept methods using GET. You cannot post to this url.

Are you getting standard differences like the data you send to this endpoint will show up in the browser url after? var = value

So you can execute a get request ... yoururl.com/pri/SuperUser/ResetPassword.qib

0


source


If your data is sensitive, it is better to use the POST method , because it will not reflect the URL, unlike GET .

0


source







All Articles