getting directory listing from Controller
Dear all,
I am new to Spring MVC, and in my first project, I want to show the user a list of html files, and let him choose one to look at. The html files are in the resources folder.
The controller needs to create a list of such files to pass to the JSP. How do I access the resources folder?
From other posts on this forum, and elsewhere, I have learned of several solutions, none of which I can get to work.
I can do this:
1) Have my controller implement ServletContextAware, and then get do this:
String path = this.servletContext.getContextPath();
2) Use a FileSystemResource like this
FileSystemResource r = new FileSystemResource("resources/");
None of these get me anywhere near the resources folder
Using both options, like this:
this.servletContext.getResourcePaths(rp);
System.out.println("rp:" + rp);
File dir = new File(rp.substring(1));
String s = dir.getAbsolutePath();
System.out.println("path:"+s);
FileSystemResource r = new FileSystemResource("resources/");
String s2= r.getDescription();
System.out.println("s2"+ s);
Under STS server, I get this:
path:C:\Program Files\springsource\sts-2.7.0.RELEASE\Spring1\resources
s2file [C:\Program Files\springsource\sts-2.7.0.RELEASE\resources]
and C:\Program Files\springsource\sts-2.7.0.RELEASE does not even contain my Spring1 project, let alone a resources folder.
What am I doing wrong?
Thank you for your attention.