Recognize Map in JSP



  • I've got the next request processing I'm sending Map into jsp using the 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";
        ...
    }
    

    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 need to know the size of this Map in jsp.

    I tried to do this:

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

    but value ${teamsForSelect.size} Nothing's coming back.

    How do I know the size of this Map?



  • Connect.

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

    Dimension, respectively:

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



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2