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

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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

Regards,

Jorge

1 Comment

action="/personaListFormSent" is not a good idea. The form will be send to localhost:8080/personaListFormSent. The best way is use of ${pageContext.request.contextPath}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.