jsp里的${}和jquery template的${} 怎么样转义

6 篇文章 0 订阅


http://www.infoq.com/cn/news/2010/10/jQuery-Template 

http://api.jquery.com/category/plugins/templates/

ms发布的jquery模板插件
在这个插件里他使用的变量占位符和jsp的el表达式用的是一样的${}, 所以在用jsp作为服务器端的输出时要进行转义, 不然jsp会把原本是属于jquery模板插件的变量也进行了替换. 以下介绍两种方式


1. escapse ${} in JSP page

<script id="clientTemplate" type="text/html">
<li><a href="clients/${id}">${name}</a></li>
</script>

进行转义后

<script id="clientTemplate" type="text/html">
<li><a href="clients/${'${'}id}">${'${'}name}</a></li>
</script>

2. save jQuery template as separated file and disable its EL evaluation

if you have a lot of jQuery templates, it's better to extract them out to a seperated file. 不使用el表达式

<%@ page isELIgnored="true" %>
<script id="clientTemplate" type="text/html">
<li><a href="clients/${id}">${name}</a></li>
</script>
<script id="anotherTemplate" type="text/html">
<li><a href="clients/${id}">${name}</a></li>
</script>

Then include this file in your JSP pages need template:

<jsp:include page="jqTemplate.jsp"></jsp:include>

http://www.infoq.com/cn/news/2010/10/DataLink-jQuery  Data Link:jQuery的数据绑定插件


http://code.google.com/p/jquery-utils/  jquery 工具集, 包含字符串格式化处理, cookie, 数组, 国际化处理.



  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值