我有一个基于Spring Web模型 - 视图 - 控制器(MVC)框架的项目。在WebLogic Server版本上部署的Spring Web模型 - 视图 - 控制器(MVC)框架版本为3.2.8:12.1.2.0.0 我在JSP中有这段代码
<script src="${contextPath}/scripts/jquery.min.js" type="text/javascript">
var optionsEUCountriesArray = [];
var optionsNonEUCountriesArray = [];
<c:forEach items="${countries}" var="country" varStatus="status">
var option${country.id} = new Option("${country.id}","${country.description}");
<c:choose>
<c:when test="${country.euMember}">
optionsArray.push(option${country.id});
</c:when>
<c:when test="${not country.euMember}">
optionsArray.push(option${country.id});
</c:when>
</c:choose>
</c:forEach>
</script>
<script src="${contextPath}/scripts/selectbox.js" type="text/javascript"></script>
在selectbox.js
内我使用变量optionsEUCountriesArray
,但我收到了此错误
Uncaught ReferenceError: optionsEUCountriesArray is not defined
答案 0 :(得分:0)
你正在组合脚本。可能这应该解决你的问题..
<script src="${contextPath}/scripts/jquery.min.js" type="text/javascript"> </script>
<script>
var optionsEUCountriesArray = [];
var optionsNonEUCountriesArray = [];
<c:forEach items="${countries}" var="country" varStatus="status">
var option${country.id} = new Option("${country.id}","${country.description}");
<c:choose>
<c:when test="${country.euMember}">
optionsArray.push(option${country.id});
</c:when>
<c:when test="${not country.euMember}">
optionsArray.push(option${country.id});
</c:when>
</c:choose>
</c:forEach>
</script>