8

i want to render data

this is how my jsp page table look like  this is what a table look like

how i achieve this,

please help me,

it creates a lot of confusion for me, that how many classes are to be define and what are the fields.

thanks

1 Answer 1

18

Most likely your data is coming from database and this is kind of List of javabeans returned.

Let's say this is:

List<MyObjects> objects

You need to set it in controller level:

@RequestMapping(value="/table")
public ModelAndView renderTable() {
    ModelAndView mv = new ModelAndView("/table"); 
    mv.add("objects",objects);
    return mv;
}

Now this is the way you render it on the JSP:

<c:if test="${not empty objects}">
    <table>
        <c:forEach var="o" items="${objects}">
            <tr>
                <td>${o.id}</td>
                <td>${o.name}</td>
                <td>${o.descriptio}</td>   
            </tr>
        </c:forEach>
    </table>
</c:if>

You can read about it more here: http://static.springsource.org/spring/docs/3.0.1.RELEASE/reference/html/view.html

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for your answer.But,It will not work unless you add a dollar symbol before all the jstl statements.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.