1

I have a table like this in my jsp page.

<c:if test="${not empty resultMap}">
    <table>
        <tr>
            Id:
        </tr>
        <tr>
            Name:
        </tr>
        <tr>
            Date:
        </tr>
    <c:forEach items="${resultMap}" var="result">
        <tr>
            <td>
                ${result.entryId}
            </td>
            <td>
                ${result.entryName}
            </td>
            <td>
                ${result.entryDate}
            </td>
            <td>
                <a href="viewEntry.htm">View</a><
            </td>
        </tr>
    </c:forEach>
    </table>
</c:if>

Which results following output.

Id:      Name:   Date:
1        test    20-12-2013 View
2        test1   20-12-2014 View

Now my requirement is to show the entry details in another page. ie, when "View" link is clicked on entry with Id 1, I need to show its details in a separate page.

So how do I pass the resultMap and entryId for which the "View" link is clicked to a controller?

Is this possible via Spring MVC? Or any other technology like ajax or jquery should be used?

Thanks, Midhun

1 Answer 1

3

You don't pass the resultMap. You only pass the ID of the entry:

<a href="<c:url value='viewEntry.htm'>
             <c:param name='entryId' value='${result.entryId}'>
         </c:url>">View</a><

The controller will then get the entryId from the request parameters, load the details of the entry from the database (thanks to the entry ID, uniquely identifying the entry), and forward to the details view.

You could also pass the ID as part of the url path directly. It all depends on the kind of URL you want, and on how you have configured your controller:

<a href="viewEntry/${entryId}.htm">View</a>
Sign up to request clarification or add additional context in comments.

2 Comments

This is working and got it as a string. How do we pass result object then?
The result is in your database. Why would you pass it from the browser?

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.