I have the following request handler in which I pass the Map to jsp using the addTeamstoModelForSelecting(teamsForSelect, teams, model) method addTeamstoModelForSelecting(teamsForSelect, teams, model) .

 @RequestMapping(value = "/{seriesGameName}", method = RequestMethod.GET) public String getTeamInfoGet(@PathVariable("seriesGameName") String seriesGameName, Model model) throws SQLException, ClassNotFoundException { Games games = seriesGamesRepository.getSeriesGames(seriesGameName); model.addAttribute("games", games); ... ArrayList<Team> teams = seriesGamesRepository.getTeamWhenHasNotInTeamsList(seriesGameName); addTeamstoModelForSelecting("teamsForSelect", teams, model); model.addAttribute("selectingTeam", new Team()); return "pages/seriesGames/seriesGamesNotStart"; ... } 

The method itself:

 private void addTeamstoModelForSelecting(String tagName, ArrayList<Team> teams, Model model) { Map<String,String> teamsMap = new LinkedHashMap<String,String>(); for(Team t : teams){ teamsMap.put(""+t.getId(), t.getId()+": "+t.getName()); } model.addAttribute(tagName, teamsMap); } 

I don't need to know the size of this Map in jsp.

I tried to do this:

 <c:if test="${teamsForSelect.size > 0}"> 

but the value of ${teamsForSelect.size} does not return anything.

How can I find out the size of this Map?

    1 answer 1

    Connect

     <%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%> 

    Size accordingly:

      <c:if test="${fn:length(teamsForSelect) > 0 }">