Home > Article > Web Front-end > JSTL tag library implements loop output of values in Map
This time I will bring you the JSTL tag library to realize the loop output of the value in the Map, which is mainly reflected in the form of code. Since the EL expression does not support the loop output of the value in the Map, it is necessary to If you loop through the Map, you must use JSTL. The following is a practical case, let's take a look.
This is the action corresponding to the Map
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { Map map = new HashMap(); map.put("k1", "冯江红,你可笑了"); map.put("k2", "想不到你也有今天"); map.put("k3", "这就是苦的滋味,尝到了吗"); request.setAttribute("maps", map); return mapping.findForward("success"); }
You can find it on the page Take it out like this
<li>利用JSTL循环的方式全出Map中的值</li><br> <c:forEach items="${maps}" var="map"> Map键:${map.key }<br> Map值:${map.value }<br> </c:forEach>
Related recommendations:
Jstl tag loops to output the data in the Map
Java loop traversal output map method
How to output the value in Map
The above is the detailed content of JSTL tag library implements loop output of values in Map. For more information, please follow other related articles on the PHP Chinese website!