Question

I need help with a very simple problem I have in my web app using Spring MVC. controller1 retrieves a list of objects from a database that are displayed in jsp1. In my jsp1, each object is represented by a link that redirects to controller2. I want to have the object represented by that link in controller2 (or the full list of objects).

These are controller 1 and controller 2:

@RequestMapping(value = "/mapping1", method = RequestMethod.GET)
public String controller1(Map<String, Object> map, HttpServletRequest request) {
    List testList = service.getList(request.getParameter("testParam"))
    map.put("testList", testList);
    return "jsp1";
}

@RequestMapping(value = "/mapping2", method = RequestMethod.GET)
public String controller2(Map<String, Object> map) {
    // How to get testObject (or testList) here?
    return "jsp2";
}

And this is jsp1:

<c:forEach items="${testList}" var="testObject">
    <tr><a href="/mapping2">${testObject.name}</a></tr>
</c:forEach>

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top