当前位置: 首页 > 工具软件 > Trimpath > 使用案例 >

jsp页面中TrimPath模版使用问题

萧萧迟
2023-12-01
按照官方网站我做了一个HTML可以正确的看到需要的效果,但是把文件改成JSP之后${}就不能取到值了,HTML代码如下:
<html>
<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script language="javascript" src="/js/trimpath-template-1.0.38.js"></script>
<script language="javascript">
var data = {"DataList":[{"OrderTypeID":"9","CurrencyID":"1","Money":"132.00","OrderID":"6117","HeXiaoTime":"","HeXiaoUserID":"","FeeTypeID":"","HeXiaoName":"","FeeCategory":"1","IsDaiShouDaiFu":"0","CreaterName":"","Status":"0","InvoiceCode":"","ZhiPiaoCode":"","CreateTime":"2013-05-07 12:51:04.34","CustomerID":"","ReceiverID":"","CreaterID":"","ID":"13","Remark":"","Currency":"美元","FeeName":"","Rate":"1.000000"},{"OrderTypeID":"9","CurrencyID":"1","Money":"132.00","OrderID":"6117","HeXiaoTime":"","HeXiaoUserID":"","FeeTypeID":"","HeXiaoName":"","FeeCategory":"1","IsDaiShouDaiFu":"0","CreaterName":"","Status":"0","InvoiceCode":"","ZhiPiaoCode":"2322","CreateTime":"2013-05-07 12:51:13.07","CustomerID":"","ReceiverID":"","CreaterID":"","ID":"14","Remark":"","Currency":"美元","FeeName":"","Rate":"1.000000"}]}

function ggg()
{
var result = TrimPath.processDOMTemplate("cart_jst", data);
document.getElementById("outputDiv").innerHTML = result;
document.getElementById("outputDiv").style.display = "block";
}
</script>
</head>

<body>
<div id="outputDiv"></div>
<textarea id="cart_jst" style="display:none;">
<table>
<tr><td>Name</td><td>Description</td>
<td>Price</td><td>Quantity & Alert</td>
</tr>
{for fee in DataList}
<tr><td>${fee.ID}</td><td>${fee.Money}</td>
<td>${fee.Rate}</td><td>${fee_index}</td>
</tr>
{forelse}
<tr><td colspan="4">No products in your cart.</tr>
{/for}
</table>
</textarea>

<input type="button" value = "asdfdasf" onClick="ggg()">

</body>
</html>


JSP页面的代码如下:

<%@ page contentType="text/html; charset=utf-8"%>
<%@ page import = "java.util.*"%>

<html>
<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript" src="/js/trimpath-template-1.0.38.js"></script>
<script language="javascript">
var data = {"DataList":[{"OrderTypeID":"9","CurrencyID":"1","Money":"132.00","OrderID":"6117","HeXiaoTime":"","HeXiaoUserID":"","FeeTypeID":"","HeXiaoName":"","FeeCategory":"1","IsDaiShouDaiFu":"0","CreaterName":"","Status":"0","InvoiceCode":"","ZhiPiaoCode":"","CreateTime":"2013-05-07 12:51:04.34","CustomerID":"","ReceiverID":"","CreaterID":"","ID":"13","Remark":"","Currency":"美元","FeeName":"","Rate":"1.000000"},{"OrderTypeID":"9","CurrencyID":"1","Money":"132.00","OrderID":"6117","HeXiaoTime":"","HeXiaoUserID":"","FeeTypeID":"","HeXiaoName":"","FeeCategory":"1","IsDaiShouDaiFu":"0","CreaterName":"","Status":"0","InvoiceCode":"","ZhiPiaoCode":"2322","CreateTime":"2013-05-07 12:51:13.07","CustomerID":"","ReceiverID":"","CreaterID":"","ID":"14","Remark":"","Currency":"美元","FeeName":"","Rate":"1.000000"}]}

function ggg()
{
var result = TrimPath.processDOMTemplate("cart_jst", data);
document.getElementById("outputDiv").innerHTML = result;
document.getElementById("outputDiv").style.display = "block";
}
</script>
</head>

<body>
<div id="outputDiv"></div>
<textarea id="cart_jst" style="display:none;">
<table>
<tr><td>Name</td><td>Description</td>
<td>Price</td><td>Quantity & Alert</td>
</tr>
{for fee in DataList}
<tr><td>${fee.ID}</td><td>${fee.Money}</td>
<td>${fee.Rate}</td><td>${fee_index}</td>
</tr>
{forelse}
<tr><td colspan="4">No products in your cart.</tr>
{/for}
</table>
</textarea>

<input type="button" value = "asdfdasf" onClick="ggg()">

</body>
</html>
 类似资料: