Can I use <spring:url value="/something" />
inside of an <a>
tag?
The Spring MVC form tags are the configurable and reusable building blocks for a web page. These tags provide JSP, an easy way to develop, read and maintain. The Spring MVC form tags can be seen as data binding-aware tags that can automatically set data to Java object/bean and also retrieve from it.
In the index. html file we have a link that invokes a response from the web application. The file is located in the src/main/resources/static directory, which is a default directory where Spring looks for static content.
Spring's form tag library is integrated with Spring Web MVC. It gives the tag access to the command object and reference data the controller deals with. The implementation of all the tags in the Spring tag library is available in org. springframework.
<spring:url value="/something" var="url" htmlEscape="true"/> <a href="${url}">...</a>
But you an also use c:url
<c:url value="/something" var="url"/> <a href="<c:out value='${url}'/>">...</a>
The one important difference between c:url
and spring:url
is, that c:url
does not html encode the created url. But for a valid url the &
between the url parameters must be a &
. So you need the c:out
to escape it. -- In spring:url
you have this functionality already included (if I understand the documentation correct).
Namespaces:
xmlns:spring="http://www.springframework.org/tags"
xmlns:c="http://java.sun.com/jsp/jstl/core"
http://docs.spring.io/spring/docs/3.0.x/spring-framework-reference/html/spring.tld.html#spring.tld.url
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With