Spring MVC: Relative URL problems

I have a controller bound the URL: "/ruleManagement".

Inside my JSP, I have a form that forwards (on submit) to "ruleManagement/save" url. When there are errors with the input fields, I want it to return back the original form View. This is where the problem starts...

Problem 1) Now that the URL is "/ruleManagement/save", my form submit now points to "/ruleManagement/ruleManagement/save".

Problem 2) I tried using spring:url tag to generate the absolute paths for me, which usually works great. But when I put a spring:url tag inside of a tag, the spring:url tag does not get parsed correctly.

<form:form action="<spring:url value='/ruleManagement/save' ...>" method="post">

When I analyze the DOM after the page loads, my form tag looks something like:

<form action='<spring:url value="/ruleManagement/save" />' ... >

If I don't use the spring:url tag, and instead use just "/ruleManagement/save", the url generated excludes my application name in the url, which is also wrong.

How do I generate a consistent URL pattern across all Views regardless of path? If the answer is "using spring:url", how do I get that content inside a form:form tag?

12
задан Corey 28 October 2010 в 16:43
поделиться