gpt4 book ai didi

java - 如何显示包含对象 HashMap 的模型的值?

转载 作者:行者123 更新时间:2023-12-01 05:10:34 26 4
gpt4 key购买 nike

我有一个 HashMap ,如下所示:

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

其中的数据如下所示:

{CompanyName=null, CompanyId=null}

我想迭代它并在我的表示层中显示它的值。我将其添加到我的模型中,如下所示:public String

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?

最佳答案

尝试像下面这样可能会起作用

${company["CompanyName"]} 

关于java - 如何显示包含对象 HashMap 的模型的值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12074759/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com