How to escape the ${} and jquery template ${} in the JSP __js

Source: Internet
Author: User


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

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

MS-released jquery template plugin
In this plug-in he uses the variable placeholder and the JSP's El expression is used in the same ${}, so in the JSP as the server side of the output to be escaped, otherwise JSP will be the jquery template plug-ins are the variables are also replaced. Here are two ways to do this


1. Escapse ${} in JSP page

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

after the escape

<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. Do not use an EL expression

<%@ 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 binding Plug-in for Link:jquery


Http://code.google.com/p/jquery-utils/jquery toolset, containing string formatting processing, cookies, arrays, internationalization processing.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.