如何使用<spring:url/>带有 <a>标签? [英] How to use <spring:url /> with an <a> tag?

查看:33
本文介绍了如何使用<spring:url/>带有 <a>标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以在 标签内使用 吗?

Can I use <spring:url value="/something" /> inside of an <a> tag?

推荐答案

 <spring:url value="/something" var="url" htmlEscape="true"/>
 <a href="${url}">...</a>

但你也使用 c:url

But you an also use c:url

 <c:url value="/something" var="url"/>
 <a href="<c:out value='${url}'/>">...</a>

c:urlspring:url 之间的一个重要区别是,c:url 不对创建的 url 进行 html 编码.但是对于有效的 url,url 参数之间的 & 必须是 &.所以你需要 c:out 来转义它.-- 在 spring:url 中,你已经包含了这个功能(如果我理解文档正确的话).

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 &amp;. So you need the c:out to escape it. -- In spring:url you have this functionality already included (if I understand the documentation correct).

命名空间:

  • 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

这篇关于如何使用&lt;spring:url/&gt;带有 &lt;a&gt;标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆