views:

35

answers:

1

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?

+5  A: 

Custom tags in JSP can't be used in attributes of other custom tags, so you need to store intermediate result in a request attribute (using var to redirect output of the tag to the request attribute is a common idiom supported by many tags):

<spring:url var = "action" value='/ruleManagement/save' ... />
<form:form action="${action}" method="post"> 
axtavt
perfect thanks!
Corey