2
votes

I have spring boot application and i'm using embedded tomcat as web server. I have problem with listing directories. I want to now how could i enable or disable listing directories in embedded tomcat. In none spring boot application we can do it adding code below in web.xml:

<init-param>
       <param-name>listings</param-name>
       <param-value>false</param-value>
</init-param>

how can i Enable/disable directory listing in spring boot?

I have found only question below in stackoverflow but didnt help.

Embedded Tomcat directory listing for spring-boot application

1
I even doubt if you enable it it would work. As there aren't directories there are only jar files and class path entries as everything is in a single jar and it isn't extracted to the file system (as a regular deployment on tomcat would do). - M. Deinum
is it a jar or war - gladiator
@M.Deinum yes you are right, it doesn't extracted to the file system in order to list directories inside of it. - Hadi Rasouli
@gladiator my project package is in war - Hadi Rasouli
And it won't get extracted. So as mentioned enabling file listing won't help. - M. Deinum

1 Answers

0
votes

When it comes to spring-boot, pretty much everything can be micro-managed via configuration files.

You can pass init-param values to the embedded container using the following properties

server.servlet.jsp.init-parameters.*= # Init parameters used to configure the JSP servlet.

in your case,

server.servlet.jsp.init-parameters.listings=false