Reputation: 93
I want to transfer data from JSP1 to JSP2. Data is being sent to JSP1 from Controller class (Spring MVC).
ModelAndView model = new ModelAndView("JSP1.jsp");
Data sent from Spring MVC Controller to JSP1
model.addObject("documetIdentity", document.getDocumentIdentity());
I want to call JSP2
in JSP1
and the data in "documetIdentity"
is to be accessible in JSP2
. I am using foreach on documetIdentity in JSP1.
Upvotes: 0
Views: 91
Reputation: 498
use ModelMap in your Controller
@RequestMapping("/welcome")
public String helloWorld(ModelMap model) {
String message = "Simplemente hola";
model.addAttribute("msg", message);
return "/welcome";
}
then in your JSP get the value
....
<div id="messageDiv" class="message primary"> ${msg} </div>
....
Maybe you want to make a validation
<c:if test="${fn:length(msg) > 0}">
<div id="messageDiv" class="message primary"> ${msg} </div>
</c:if>
Good luck!
Upvotes: 1