In my Spring application when i click on the submit button on my form reloads the page, i’m sure i had forgotten something but i can’t see the error
In the jsp, I’m creating the form like this:
<form:form commandName="municipioBean" method="POST">
<label for="df_mun">Estado</label>
<form:select path="df_edo" name="df_edo" id="df_edo"
onchange="getMunicipios();">
<form:option value="0">Seleccione un estado...</form:option>
<form:options items="${listaEstado}" itemValue="codProvincia"
itemLabel="desProvincia" />
</form:select>
<label for="df_mun">Municipio</label>
<form:select path="df_mun" name="df_mun" id="df_mun">
<option selected value="0">Seleccione un estado primero...</option>
</form:select>
<form:hidden id="id_ciudadano" path="id_ciudadano" />
<input type="submit" name="procesar" value="Aceptar" />
</form:form>
And my controller:
@RequestMapping(method = RequestMethod.POST, params = "procesar")
public String procesaSubmit(
@ModelAttribute("municipioBean") MunicipioBean municipioBean,
BindingResult result, HttpServletRequest request, ModelMap model) {
return ConstantesAbre.PASOS_JSP;
}
Params value is equal to the name of my submit button and the RequestMethod it’s ok too, what’s the problem?.
Thanks in advice and sorry for my bad english D:
You need to add a value in your @RequestMapping usually the name of the page.
For example
I usually set up my controllers with the base path decalred at the top of the class like this:
So your full path would be something like
http://server:port/application/main/theJspNameThere could also be an extension depending on how you set up your ViewResolver.
Also make sure that you have
defined somewhere in your app-servlet.xml or applicationContext.xml file.
Hope that helps a little.