1

I'm new to struts2,In fact new to web application development just started developing a sample application. Currently I'm using struts tiles concept in my project. Here is how I am referring to tiles.xml in my application.

 <listener>
            <listener-class>
                org.apache.struts2.tiles.StrutsTilesListener
            </listener-class>
    </listener>
    <context-param>
            <param-name>tilesDefinitions</param-name>
            <param-value>/WEB-INF/tiles.xml</param-value>
    </context-param>

I'd like to place tiles.xml to resources folder of application, despite of placing it inside web-inf folder. How can I refer to that in web.xml.

srk
  • 4,857
  • 12
  • 65
  • 109
  • I just want to organize my folders in my web application, so that resources has as the stuff, like *.xml(struts.xml,tiles.xml), *.properties(MessageBundle.properties). How can I achieve this ? – srk Nov 20 '12 at 15:45

1 Answers1

2

Moving configuration files from their original location is something dangerous, and shold be examined case by case.

But usually you can use a trick: place a stub xml configuration file in the place where it is expected to be, that contains only the include of the real file, located out of the WEB-INF (or inside it but in another location):

<struts>
   <include file="..\struts.xml"/>
</struts>

As described here: http://struts.apache.org/2.x/docs/struts-1-solutions.html

For properties it's harder... be careful

Andrea Ligios
  • 49,480
  • 26
  • 114
  • 243
  • gratitude, for your valuable suggestion. I realized that it's not needed to change its position from web-inf. – srk Nov 20 '12 at 16:46
  • 1
    I'm not sure this isn't a bad thing to do. Tiles is able to loads it's definitions even from a DB, I don't think it is too eyebrow raising to move the xml configuration file anywhere. – Quaternion Nov 22 '12 at 01:15
  • You say "Why not?", I say just "Why ?"... it violates YAGNI :))) – Andrea Ligios Nov 22 '12 at 08:30
  • While from DB it could make sense: you could change the definition at runtime. On file system instead, even if outside the web application, it would be hard to change something on a production server without a release... +1 for DB idea :) – Andrea Ligios Nov 22 '12 at 08:50