Show files in the folder in front

I have a middle tier web application in Java, front end in JS, angular.

Inside my war file, the folder structure looks like this:

myApp.war/css
myApp.war/images
myApp.war/js
myApp.war/files

      

the file folder looks like this:

myApp.war/files/file1.txt
myApp.war/files/file2.txt

      

Now in my application I have files for displaying buttons. Here I want to provide links to all files present in the file folder.

I can access the files file1.txt and file2.txt like this:

http://myserver.com:1225/myApp/files/file1.txt
http://myserver.com:1225/myApp/files/file2.txt

      

I can create links in my html and I will, but the problem is that the filenames will change dynamically. So I can't guess how many files are present in the file folder and their names.

So, I wonder if I can display all the files present in the linked files folder.

I am getting Error 404: SRVE0190E: File not found when accessing http://myserver.com:1225/myApp/files/

Any thoughts

+3


source to share


1 answer


You need to enable directory browsing for your application. In WEB-INF create a file ibm-web-ext.xml

with the following content (key element <enable-directory-browsing value="true"/>

):



<?xml version="1.0" encoding="UTF-8"?>
<web-ext
   xmlns="http://websphere.ibm.com/xml/ns/javaee"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee   http://websphere.ibm.com/xml/ns/javaee/ibm-web-ext_1_1.xsd"
   version="1.1">

   <reload-interval value="3"/>
   <enable-directory-browsing value="true"/>
   <enable-file-serving value="true"/>
   <enable-reloading value="true"/>
   <enable-serving-servlets-by-class-name value="false" />
</web-ext>

      

+1


source







All Articles