Add a parameter to a JSTL c:url after creation
Nice when you’re using URLs in a bunch of different places that differ only by a parameter or two.
<c:url value=”http://www.google.com” var=”my_google_link”><c:param name=”query” value=”lookforit” /></c:url>
<c:url value=”my_google_link” var=”my_new_google_link”><c:param name=”pagenum” value=”5″ /></c:url>
<c:out value=”${my_new_google_link}” escapeXml=”true” />
This results in: http://www.google.com?pagenum=5&query=lookforit
Note that using escapeXml in your <c:out /> has the added benefit of giving you some sweet XHTML-compliant link action (i.e. ampersands are escaped.)
Thanks for good post! Thats what i’ve been looking for.
Thanks for the good work you have done!!
I would like to mention that line:
should be written as:
<c:url value="${my_google_link}" var=â€my_new_google_linkâ€>
.