Where to put struts.xml

ariso picture ariso · May 15, 2009 · Viewed 32.6k times · Source

With Struts2 we have to have struts.xml in the class path, so it no longer works to have it under WEB-INF. So the way I got my project to deploy was to stick it under WEB-INF/classes and have it include ../struts2.xml

2 Problems:

  1. Eclipse cleans out the classes folder when I do a rebuild, so it deletes struts.xml
  2. Eclipse doesn't show the classes folder in my project browser, so its a poor place to stick config files in the first place.

How are you Struts2 Eclipse developers doing this?

Answer

Peter Kelley picture Peter Kelley · May 16, 2009

You can either just put the struts.xml at the root of your source directory or set up an additional resources source directory and put it there. Eclipse quite happily copies it to WEB-INF/classes for you when it does a compilation.