I have a doubt about the best way to handle the @RequestMapping
.
For example:
with this url http://localhost:8080/SpringExample/admin/personaListForm/1
I reach a form, controlled by this @RequestMapping:@RequestMapping("/admin/personaListForm/{tipoPersona}")
As you can see "1" is a variable.
This is my form:<form:form action="personaListFormSent">
As you can see, If I submit the form, I'll be sent to this url http://localhost:8080/SpringExample/admin/personaListForm/personaListFormSent
(because of the "/1").
The problem is that i don't want to go there, I want to go to http://localhost:8080/SpringExample/admin/personaListFormSent
I may solve the problem editing the form this way <form:form action="../personaListFormSent">
but it doesn't seem a professional way to handle this problem, since if tomorrow I need to add more variable I'll have to add more "../" to the form tag.
thank you
You can use ${pageContext.request.contextPath}/personaListFormSent
.
<form:form action="${pageContext.request.contextPath}/personaListFormSent">
So you will go to http://localhost:8080/SpringExample/personaListFormSent when you post the form.