2012-08-22 27 views
1

我有一個HashMap如下:如何顯示包含對象的HashMap的模型的值?

HashMap<String, Object> myHashMap = new HashMap<String, Object>(); 

的數據在它看起來像這樣:

{CompanyName=null, CompanyId=null} 

我想從它遍歷這個與顯示值在我的表現層。 我把它添加到我的模型如下:公共字符串

showPage(Map model) 
{ 
     HashMap<String, Object> myHashMap = new HashMap<String, Object>(); 

     model.put("company", myHashMap); 

     return "page"; 
} 

我國JSP

<h1>${companyName}</h1> 

<fieldset> 
    <p> 
     <form:label path="companyName" cssErrorClass="form-error">Issuer Name</form:label> 
    </p> 
</fieldset> 
<input type="submit" value="Next" class="round blue ic-right-arrow" /> 

,我得到以下錯誤:

Caused by: org.springframework.beans.NotReadablePropertyException: Invalid property 'companyName' of bean class [java.util.HashMap]: Bean property 'companyName' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter? 
+0

似乎是一個過早的提交? – Vikdor

回答

0

嘗試像下面它可能工作

${company["CompanyName"]}