简体   繁体   中英

display data in jsp using jstl

I am new to JSTL .I want display data from a list in JSP .How to do this.I tried something.I am using eclipse luna.

My Status.jsp file

<%@ page import="javax.servlet.jsp.jstl.core.*"%>
<%@ page import="javax.servlet.jsp.el.*" %> 

<c:foreach items="${statusdisplay}" var="statuslist">

            <div class="row">
                <div class="col-md-6 col-sm-12 col-xs-12">
                    <div class="input-group  col-xs-12">
                            <span class="input-group-addon iga">Screen</span>
                            <input type="text" class="form-control" value= "${statuslist.getScreen()}" readonly>
                    </div><br>

                    <div class="input-group col-xs-12">
                            <span class="input-group-addon iga">Show</span>
                            <input type="text" class="form-control" value="${statuslist.getShow()}" readonly>
                    </div><br>
            </div>
</c:foreach>

My Servlet code

request.setAttribute("statusdisplay", statuslist);

            RequestDispatcher requestdispatcher=request.getRequestDispatcher("/Status.jsp");
            requestdispatcher.forward(request,response);

When i run the program without taglib it not showing error and also no output in jsp. when i add <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> it is show No tag "foreach" defined in tag library imported with prefix "c"

How to display data??

You have typo for <c:forEach> tag , its foreach in your code . Also you can simply use variables declared in the model class as ${statuslist.screen} and ${statuslist.show} .

see How to avoid Java code in JSP files?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM