0
我有以下屬性文件:如何基於屬性文件的多個HTML項目?
title = Welcome to Home Page
total = 5
gallery1 = images/gallery/cs.png
text1 = <b>Counter Strike</b><br />
gallery2 = images/gallery/css.png
text2 = <b>Counter Strike Source Servers Available</b>
gallery3 = images/gallery/cs.png
text3 = <b>Counter Strike</b>
gallery4 = images/gallery/cs.png
text4 = <b>Counter Strike</b>
gallery5 = images/gallery/cs.png
text5 = <b>Counter Strike</b>
我加載它,如下所示:
public static HashMap<String, String> getPropertyMap(String asPropBundle) throws ApplicationException {
HashMap<String, String> loMap = new HashMap<String, String>();
ResourceBundle loRB = (ResourceBundle) moHMProp.get(asPropBundle) ;
if (loRB == null) {
throw new ApplicationException("No property bundle loaded with name: " + asPropBundle);
}
Enumeration<String> loKeyEnum = loRB.getKeys();
while (loKeyEnum.hasMoreElements()) {
String key = (String) loKeyEnum.nextElement();
loMap.put(key, loRB.getString(key));
}
return loMap ;
}
返回的映射設置爲HTTP請求屬性。
我生成JSP中的HTML如下:
<li class="s3sliderImage">
<img src="${map.gallery1}" />
<span>${map.text1}</span>
</li>
.
.
.
<li class="s3sliderImage">
<img src="${map.gallery2}" />
<span>${map.text2}</span>
</li>
我怎樣才能在一個循環中動態地做到這一點?我在屬性文件的total
財產記錄的總量。
好一點,但是這不正是在OP *實際上*在問。 – BalusC
啊,好的。我錯過了問題的最後部分。我會編輯我的答案。 –
@JBNizet得到錯誤...在org.apache.jasper.servlet.JspServlet.handleMissingResource(JspServlet.java:335) – Varun