File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other Application Frameworks and the fly likes SpringMVC Model Object in JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "SpringMVC Model Object in JSP" Watch "SpringMVC Model Object in JSP" New topic
Author

SpringMVC Model Object in JSP

Ansar Shah
Greenhorn

Joined: May 02, 2007
Posts: 29
Hello

I am building a dynamic page, that gets its html contents from the model object passed to jsp using ModelAndView type. The html content is passed to jsp but the html code gets displayed as it is on the page. Like if i pass "<table><tr><td>Hello!</td></tr></table", this string would display on the page but no actual table. I am using following code in the jsp page.

<c:forEach items="${model.criCellList}" var="cell"><c ut value="${cell.cellContents}" />
</c:forEach>

Can any one help?
Ansar Shah
Greenhorn

Joined: May 02, 2007
Posts: 29
I have just seen that the compiled jsp page source is showing
" < " in place of " < " in my dynamically generated html.

I dont know why this is happening.. Please help..
Ansar Shah
Greenhorn

Joined: May 02, 2007
Posts: 29
Well ! its even working in the ranch page then why dont on my page. . I meant to say .
sruthi das
Ranch Hand

Joined: Dec 28, 2007
Posts: 34
try like this for example
this is in my controller.
return new ModelAndView("View_printer_detail.jsp", "Model", persons);
and in my jsp
<c:forEach var="log1" items="${Model}">
<tr><td> <c ut value="${log1.printerid}" /> </td><td> <c ut value="${log1.ipaddress}" /> </td><td><c ut value="${log1.storeid}"/></td><td><c ut value="${log1.default1}"/></td></tr>
</c:forEach>
Ansar Shah
Greenhorn

Joined: May 02, 2007
Posts: 29
Thanks for the response.
Infact I want even the columns and rows to be dynamic. Why the contents from the model object dont get compiled to a html page? Is there a way out?

Thanks.
sruthi das
Ranch Hand

Joined: Dec 28, 2007
Posts: 34
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
did you import this taglibrary
Ansar Shah
Greenhorn

Joined: May 02, 2007
Posts: 29
Yes I did, no problem with this tag library as the html content is getting to the page at least.
Even when I copy the html code displayed on the page, and then paste it direct on the jsp page, then it works perfectly fine. But some how when it comes through server side, then it displays it as a text.
 
jQuery in Action, 2nd edition
 
subject: SpringMVC Model Object in JSP