0

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

MDP
  • 4,177
  • 21
  • 63
  • 119

2 Answers2

1

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.

soung
  • 1,411
  • 16
  • 33
0

Send them to action="/personaListFormSent". '/' is the root of your app, so it doesn't matter which is your context path.

Regards,

Jorge

  • action="/personaListFormSent" is not a good idea. The form will be send to http://localhost:8080/personaListFormSent. The best way is use of `${pageContext.request.contextPath}` – soung Nov 26 '15 at 09:54