freemarker标签使用注意

在使用freemarker时,在模版中,[] 和< > 只能选择其一使用,否则页面显示可能出错。例如下面代码

该页面可以正常显示,当把js中[#list]的 []改为<>, 页面中多了一部分字符串,该字符串是freemarker标签。说明解析出错,

原因:页面中freemarker标签使用不一致,因此我们知道 在模版中,[] 和< > 只能选择其一使用,

<!DOCTYPE HTML>
<html>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="keywords" content="${channel.keywords!}"/>
<meta http-equiv="description" content="${channel.description!}"/>
<title>${channel.title!channel.name} - ${site.name} -专题服务</title>
<script src="${resSys}/jquery.js" type="text/javascript"></script>
<script src="${resSys}/front.js" type="text/javascript"></script>
<script type="text/javascript" src="/${res}/js/jquery.SuperSlide.js"></script>
<link type="text/css" rel="stylesheet" href="/${res}/css/index.css" />
<script type="text/javascript" src="/${res}/js/jquery.DB_tabMotionBanner.min.js"></script>
<script type="text/javascript">

function Info(info,path){
	this.info=info;
	this.path=path;
}

function  subInfo(str){
	var size=20;
	var len=str.length;
	if(len>=size){
		return str.substr(0,size);
	}else{
		return str.substr(0,len);
	}
}
var softArray =new Array();
var patentArray =new Array();
var thesisArray =new Array();
function showLine(fileSort){
	var name=$(fileSort).attr("id");
	var obj=$("."+name);
	 if(obj.is(':hidden')){//如果当前隐藏  
		 obj.slideDown();//那么就显示div  
	 }else{//否则  
	     obj.slideUp();//就隐藏div  
	 }  
}
function showInfo(arr,names){
	var path=null;
	var tit=null;
	var index=0;
	var str="<ul>";
	var fileSort=names;
	for(var i=0;i<arr.length;i++){
		index=i+1;
		path=null;
		tit=null;
		if(arr[i].info!=null&&arr[i].info!=""){
			 tit=arr[i].info;
		}else{
			tit="";
		}
		if(arr[i].path!=null&&arr[i].path!=""&&arr[i].path.indexOf("null")==-1){
			path=arr[i].path;
		}else{
			path="#";
		}
		if(i<3){
			if(path=="#"){
				str+="<li>"+index+".<a href='"+path+"' style='text-decoration:none;color:black' title='"+tit+"'>"+subInfo(tit)+"</a></li>";
			}else{
				str+="<li>"+index+".<a href='"+path+"' style='color:blue' title='"+tit+"'>"+subInfo(tit)+"</a></li>";
			}
		}else if(i==3){
			if(path=="#"){
				str+="<li style='display:none'   class='"+names+"'>"+index+".<a style='text-decoration:none;color:black' href='"+path+"' title='"+tit+"'>"+subInfo(tit)+"</a></li>";
			}else{
				str+="<li style='display:none' class='"+names+"'>"+index+".<a style='color:blue' href='"+path+"' title='"+tit+"'>"+subInfo(tit)+"</a></li>";
			}
		}else if(i>3){
			if(path=="#"){
				str+="<li style='display:none' class='"+names+"'>"+index+".<a style='text-decoration:none;color:black' href='"+path+"' title='"+tit+"'>"+subInfo(tit)+"</a></li>";
			}else{
				str+="<li style='display:none' class='"+names+"'>"+index+".<a style='color:blue' href='"+path+"' title='"+tit+"'>"+subInfo(tit)+"</a></li>";
			}
		}
	}
	if(arr.length>3){
		str+="<li><input   id='"+names+"' style='text-align:center'   size='6' οnclick=showLine("+names+") value='更多'/></li>";
	}
	str+="</ul>";
	$("#"+names+"s").append(str);
	if(arr.length>0){
		$("#"+names).show();
	}
}
function showComp(arr,names){
	var index=0;
	var str="<ul>";
	for(var i=0;i<arr.length;i++){
		index=i+1;
		if(i<3){
			str+="<li>"+index+"."+arr[i]+"</li>";
		}else {
			str+="<li style='display:none'  class='"+names+"'>"+index+"."+arr[i]+"</li>";
		}
	}
	if(arr.length>3){
		str+="<li><input   id='"+names+"' style='text-align:center'   size='6' οnclick=showLine("+names+") value='更多'/></li>";	
	}
	str+="</ul>";
	$("#"+names+"s").append(str);
	if(arr.length>0){
		$("#"+names).show();
	}
}
[#list content.attachments as attach]
[#if attach.name?contains("thesis:")]
		thesisArray.push(new Info("${attach.intellectualPropertyInformation!}","${attach.path!}"))
	[#elseif attach.name?contains("patent:")]
		patentArray.push(new Info("${attach.intellectualPropertyInformation!}","${attach.path!}"))
	[#elseif attach.name?contains("software")]
		softArray.push(new Info("${attach.intellectualPropertyInformation!}","${attach.path!}"))
	[#else]
[/#if]
[/#list]
$(function(){
	showInfo(softArray,"software");
	showInfo(patentArray,"patent");
	showInfo(thesisArray,"thesis");
	var origins="${content.attr.origin!}";
	var originArr=null;
	if(origins!=null&&origins!=""){
		originArr=origins.split(",");
		showComp(originArr,"origin");
	}
})
$(function() {

	Cms.channelViewCount("${base}","${channel.id}");
	Cms.siteFlow("${base}", location.href, document.referrer,"${site.config.flowSwitch?string}");
});
function check(index){
	document.getElementById("excel").style.display="";
	document.getElementById("iframepage").src = index;
}
</script>
</head>
<body  style="background-color: rgb(247, 247, 247);">
[#include "../include/header-child.html"/]
<div class="main container clearfix newsTex  newsTex-yz main-content"> 
 <div class="website"><span><b> </b><a href="${base}/ztfws/index.jhtml"; target="_parent">返回专题>></a></span></div>
<div class="cont_doc_box">
	<img src="${content.attr.picture!}" width="980" height="300px" >
					<div class="detail_c">
						<table width="85.5%" align="center">
							<tbody><tr>
								<th width="20%">数据集名称</th>
								<td width="80%">${content.title}<br/>
								</td>
							</tr>
							<tr>
								<th width="20%">数据集编码</th>
								<td width="80%">${content.attr.dataSetCode!}<br/>
								</td>
							</tr>
							<tr>
								<th width="20%">数据集描述</th>
								<td width="80%">${content.attr.descrip!}<br/>
								</td>
							</tr>
							<tr>
								<th width="20%">关键字</th>
								<td width="80%">${content.shortTitle}<br/>
								</td>
							</tr>
							[#if content.attr.dataSafe !=""]
							<tr>
								<th width="20%">数据安全等级</th>
								<td width="80%">${content.attr.dataSafe!}<br/>
								</td>
							</tr>
							[/#if]
							<tr>
								<th width="20%">访问限制</th>
								<td width="80%">${content.attr.visitLimit!}
								</td>
							</tr>
							[#if content.attr.descripFile !=""]
							<tr>
								<th width="20%">全字段说明文件</th>
								<td width="80%"><a href="${content.attr.descripFile!}" target="_blank">查看</a>
									
								</td>
							</tr>
							[/#if]
							[#if content.attr.visitLimit =="公开级"]
							[#if content.attr.dataDownload !=""]
							<tr>
								<th width="20%">全字段示例数据</th>
								<td width="80%"><a href="${content.attr.dataDownload!}" target="_blank">查看</a>
								</td>
							</tr>
							[/#if]
							[/#if]
							[#if content.attr.visitLimit =="隐私级"]
							[#if content.attr.dataDownload !=""]							
							[#if user??]
							[#if user.admin]
							
							<tr>
								<th width="20%">全字段示例数据</th>
								<td width="80%"><a href="${content.attr.dataDownload!}" target="_blank">查看</a>
								</td>
							</tr>
						
							[/#if]
							[/#if]
							[/#if]
							[/#if]
							
							<tr>
							<td colspan="2" align="center" style="font-size:16px; padding:15px 0; text-align:center"><strong>负责单位信息</strong></td>
							</tr>
							<tr>
								<th width="20%">负责单位名称</th>
								<td width="80%">${content.attr.originName!}
								</td>
							</tr>
							<tr>
								<th width="20%">负责单位通讯地址</th>
								<td width="80%">${content.attr.unitAddress!}
								</td>
							</tr>
							<tr>
								<th width="20%">负责单位联系电话</th>
								<td width="80%">${content.attr.unitTelephone!}
								</td>
							</tr>
							<tr>
								<th width="20%">负责单位电子邮件</th>
								<td width="80%">${content.attr.unitEmail!}
								</td>
							</tr>
							[#if content.attr.origin !=""]
							<tr>
								<th width="20%">合作单位</th>
								<td width="80%">${content.attr.origin!}
								</td>
							</tr>
							[/#if]
							
							
							[#if content.attachments?size gt 0  || content.attr.scholar !=""|| content.attr.other !=""]
							<tr>
							<td colspan="2" align="center" style="font-size:16px; padding:15px 0; text-align:center"><strong>成果</strong></td>
							<td colspan="2"></td>
							</tr>
							[/#if]
								<tr id="thesis" style="display:none">
							<th width="20%">学术论文</th>
							<td class="wenjian_more" id="thesiss">
     						 </td>
							</tr>
							<tr id="patent" style="display:none">
							<th width="20%">专利</th>
							<td class="wenjian_more" id="patents">
     						</td>
							</tr>
							<tr id="software" style="display:none">
							<th width="20%">软件著作权</th>
							<td class="wenjian_more" id="softwares">
     						 </td>
							</tr>
							[#if content.attr.scholar !=""]
							<tr>
								<th width="20%">专著</th>
								<td width="80%">${content.attr.scholar!}
								</td>
							</tr>
							[/#if]
							
							[#if content.attr.other !=""]
							<tr>
								<th width="20%">其他</th>
								<td width="80%">${content.attr.other!}
								</td>
							</tr>
							[/#if]
							<tr>
							<td colspan="2" align="center" style="font-size:16px; padding:15px 0; text-align:center"><strong>其他信息</strong></td>
							</tr>
							<tr>
								<th width="20%">生成日期</th>
								<td width="80%">${content.attr.releaseDates!}
								</td>
							</tr>
							<tr>
								<th width="20%">更新日期</th>
								<td width="80%">${content.attr.gxsj!}
								</td>
							</tr>
							[#if content.attr.queryResource !=""]
							<tr>
							<td colspan="2" align="center" style="font-size:16px; padding:15px 0; text-align:center"><strong><a href="${content.attr.queryResource!}">资源查询</a></strong><br/>
							</td>
							</tr>
							[/#if] 
							[#if content.attr.statisticsResource !=""]
							<tr>
							<td colspan="2" align="center" style="font-size:16px; padding:15px 0; text-align:center"><strong><a href="${content.attr.statisticsResource!}">资源统计</a></strong><br/>
							</td>
							</tr>
							[/#if] 
						</tbody></table>	
					</div>					
								   
              	</div>
</div>
[#include "../include/footer.html"/]
</body>
</html>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值