-1

Hi guys I want that I have a post method in spring controller But user hits url request directly from a browser then user gets nothing. So how can I redirect this to login page in spring mvc.

3 Answers3

0

As per your description

But user hits url request directly from a browser then user gets nothing

When user hitting a URLfrom browser, it should be a GET request but you said you have POST request there. That's why nothing happens(should give

GET not supported

in browser though). POST method requests server to process submitted form data.
To achieve that, you have to declare a GET method for that URL in your controller side and return your resource(view) to the user and then user will get that after hitting that URL. After that you can perform POST request from user side(i.e. form data submission).

In one line: Your POST request will be GET in controller side if you want to just what you want.

Please let me know if I can assist more.

user404
  • 1,934
  • 1
  • 16
  • 32
0

probably you should look for security instead of look for "redirects", you can cool at this question for reference :

link to similar question

NiNiCkNaMe
  • 181
  • 5
0

It is NOT possible to make POST request from the browser.

You can find some other approaches fire-http-post-requests-with-firefox-or-chrome

Alien
  • 15,141
  • 6
  • 37
  • 57