Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
578 views
in Technique[技术] by (71.8m points)

spring boot - : EL1008E: Property or field 'LEVEL' cannot be found on object of type 'java.util.ArrayList' - maybe not public or not valid?

please assist with the below. I am trying to display an arraylist returned from the controller and display it to an Html table but I get the above error.

here is my controller code:

@GetMapping(value="/chart" )
public List<List<CanvasjsChartData.DataPointModel>> chart(Model modelMap) {
    List<List<CanvasjsChartData.DataPointModel>> dataPointsList = canvasjsChartService.getCanvasjsChartData();
    modelMap.addAttribute("dataPointsList", dataPointsList);
    System.out.println("dataPointsList");
    return dataPointsList;
}

and this is the table I want to display my list in

<table class="table" id="dataTable" style="width:100%">

<thead>
<th>Level</th>
<th>Occurences</th>
</thead>

<tbody>
<tr th:each="item :${dataPointsList}">
   <td th:text="${item.LEVEL}"> </td>
    <td th:text="${item.OCCURENCES}"> </td>
</tr>
</tr>
</tbody>

I know for sure the ArrayList has the data I require as shown below I dont know why its giving me the error arralist

question from:https://stackoverflow.com/questions/65842625/el1008e-property-or-field-level-cannot-be-found-on-object-of-type-java-uti

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Your debug shows you have an List<List<CanvasjsChartData.DataPointModel>> (two Lists inside of each other) -- when your HTML is expecting List<CanvasjsChartData.DataPointModel>. You should fix that in your controller/model by only returning a single list.

You could also display your HTML like this (where you loop over the 0th element of the outer array):

<tr th:each="item :${dataPointsList[0]}">
  <td th:text="${item.LEVEL}" />
  <td th:text="${item.OCCURENCES}" />
</tr>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...