不废话直接上代码
页面为jsp
<pre name="code" class="html"><%@ page language="java" import="java.util.List,java.util.ArrayList,java.util.HashMap, cmcc.gz.platform.emss.purchase.db.domain.PurchaseDevice,cmcc.gz.platform.emss.purchase.db.domain.PurchaseCable" pageEncoding="utf-8"%>
<% Object cableordevice = request.getAttribute("cableordevices"); %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>"> <meta http-equiv="content-type" content="text/html;charset=utf-8"> <%@ include file="/resources/page/jeasyui-resources.jsp"%> <script type="text/javascript" src="platform/emss/purchase/js/addApply.js"></script> <script type="text/javascript"> <strong>var kkk = '<%=cableordevice%>';</strong><pre name="code" class="html"><span style="white-space:pre"> </span></script>
</html>
addApply.js
alert(kkk);
意思就是说在页面上面声明的全局变量,在其引入的JS文件里面可以直接用。但要注意的一点是不能放在页面初始化的方法之内进行。
时间: 2024-10-06 05:09:18