Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Public folder exploration under Struts2 web application

Tags:

struts2

I want to publish some resources (folders and files) under a folder inside the WebContent folder of my Struts2 application and allow free directory exploration of that folder contents.

WebContent/public-folder/.

Does somebody know how to achieve this?

All my attempts fail with the classical ‘There is no Action mapped for action name public-folder’

I am using Sitemesh decorator, and have defined next exclude pattern:

<excludes>            
<pattern>/*public-folder*</pattern>
</excludes>                 

It seems that I’m unable to escape away from Struts2 control. Thanks…

like image 744
JLLMNCHR Avatar asked Jul 22 '26 15:07

JLLMNCHR


1 Answers

Warning

There is no Action mapped for action name public-folder

because of /* for filter

<filter>
    <filter-name>struts2</filter-name>
    <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

Solution

struts.xml (Preventing Struts 2 from Handling a Request)

<!-- value : regular expressions -->
<constant name="struts.action.excludePattern" value="/public-folder/.*?" />


[Tomcat] /conf/web.xml

<init-param>
    <param-name>listings</param-name>
    <param-value>true</param-value> <!-- default is false -->
</init-param>
like image 91
lschin Avatar answered Jul 26 '26 13:07

lschin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!