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 Answers
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
GETnot 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.
- 1,934
- 1
- 16
- 32
probably you should look for security instead of look for "redirects", you can cool at this question for reference :
- 181
- 5
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
- 15,141
- 6
- 37
- 57