• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Need help getting c:foreach jsp iterate over list working

 
Ranch Hand
Posts: 681
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It should be simple, but i cant get the following code to work thanks for anyhelp



here is my controller code both lists are being passed in



I cant see anything wrong with my JSP

all it outputs is

Funds:

list

which looks like outputs the text but both lists are empty.
 
Ranch Hand
Posts: 38
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you please try like this in your cotroller and see if this works...

@RequestMapping(method = RequestMethod.GET)
public ModelMap printWelcome(ModelMap model) {
......
......
return model;
}
 
Tony Evans
Ranch Hand
Posts: 681
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Vivek SharmaJi didnt work, returning the modal or return the name of the JSP page did not make a difference it can resolve strings an objects, seems to be having problems with the collections.

But thanks for your input.
 
Vivek SharmaJi
Ranch Hand
Posts: 38
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah, to me also code looks fine. I was thinking if somehow 'model' is being lost.

Also, can you please try using following as well on jsp page and see the result.

<c:out value="${fund.fundName}"/>
 
Vivek SharmaJi
Ranch Hand
Posts: 38
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah, to me also code looks fine. I was thinking if somehow 'model' is being lost.

Also, can you please try using following as well on jsp page and see the result.

<c : out value="${fund.fundName}"/>
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm having trouble reading your code with all the wonky indentation. But I do not see how your JSP could possible be printing out those labels when they do not exist in the HTML. Are you posting the real code? Or just paraphrasing it?

What is the HTML that is rendered to the browser? (View Source)
 
Tony Evans
Ranch Hand
Posts: 681
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Message : Spring 3 MVC Hello Tony
Fund Holder Id Fund Holder Name
10720031 Barlings
Fund Id Fund Name
Funds:
lists :



It looks like the collections are there its just not interating over them

Thanks
 
Tony Evans
Ranch Hand
Posts: 681
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Changed the JSP a little

these are the two foreach loops

 
Vivek SharmaJi
Ranch Hand
Posts: 38
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Seeing html it seems tld is not being resolved it should not print as follows, it should be resolved.
<c:forEach var="fund" items="

Hence please check following import and your application is able to find jstl tag lib.

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
 
Tony Evans
Ranch Hand
Posts: 681
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Vivek SharmaJi

Its now working I forgot to add <%@ taglib prefix=“c” uri=“http://java.sun.com/jsp/jstl/core”%> Thats what cpmes of not doing front end for years.
reply
    Bookmark Topic Watch Topic
  • New Topic