2017-03-09 43 views
1

我有一個基於Spring Web模型 - 視圖 - 控制器(MVC)框架的項目。春天的Web模型 - 視圖 - 控制器的版本(MVC)框架是3.2.8部署在WebLogic Server的版本:12.1.2.0.0 我有這樣的代碼在我的JSPJavascript - 在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

要結合腳本。或許這應該解決您的問題..

<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> 
+0

在此之後打電話給你selectbox.js – user7417866