I'm using Spring MVC to pass a ArrayList object from my Controller to JSP and I want to iterate it over there using JSTL (forEach), but it is always crashing Java server after 10~20 seconds loading the page. It's not throwing any exception.
Trying to use "c:out" to print the String representing the array works fine. Same to not empty validation. It always crashes when program reaches the forEach.
SIMPLIFIED EXAMPLE BELOW
Controller method
@RequestMapping(value = "/main", method = {RequestMethod.POST}, params = "create")
public ModelAndView createBranch (Branch branch) throws FxtrmServiceException, JsonGenerationException, JsonMappingException, IOException{
ModelAndView branchMV = new ModelAndView("branch");
ArrayList<String> array1 = new ArrayList<String>();
array1.add("test1");
array1.add("test2");
branchMV.addObject("alertMap1", array1);
populateAutoCompletes(branchMV);
return branchMV;
}
JSP:
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
(...)
<c:if test="${not empty alertMap1}">
<c:forEach items="${alertMap1}" var="entry1">
<c:out value="${entry1}"/><br>
</c:forEach>
</c:if>