First of all, here is my Controller :
@RequestMapping(value = "/esta", method = RequestMethod.POST) public String handleRequest(HttpServletRequest request) { Esta estaobject = new Esta(); // To test, if the parameters are set String user = request.getParameter("user"); String name = request.getParameter("name"); String shortname = request.getParameter("shortname"); String was_admin_string = request.getParameter("was_admin"); String sap_nr = request.getParameter("sap_nr"); String etl_string = request.getParameter("etl"); if (user != null && name != null && shortname != null && was_admin_string != null && sap_nr != null && etl_string != null) { some code... } request.getSession().setAttribute("esta", estaobject); return "esta"; }
When I visit a site, it checks with if -statement if there are some parameters.
If not, then it should just display my form. Then, when I fill out the form, it submits it using POST , and now there are some options, and it goes through if -statement.
My problem: when I first visit the site, this is not a POST -request, so I get the error message Request method 'GET' not supported .
But changing the form to GET -request is not an option for me. This should be a POST .
So, is there a solution for processing the same controller in POST and GET requests?
java spring model-view-controller request
Michael schmidt
source share