Win a copy of Transfer Learning for Natural Language Processing (MEAP) this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Paul Clapham
  • Devaka Cooray
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Liutauras Vilda
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Piet Souris
Bartenders:
  • salvin francis
  • Carey Brown
  • Frits Walraven

struts 2.1 config file location

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi

i'm trying to configure struts 2.1 so that it finds my struts config file under /WEB-INF/config/, but for some reason this is proving more difficult than what i thought it would be.

what i have tried so far is:

1) put the config file in the root of my java sources dir, which means that when i build my project (in eclipse) the file is copied to the classes dir and is thereby automatically put on the classpath. doing it this way means it's enough to put the following in web.xml:

<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
<init-param>
<param-name>config</param-name>
<param-value>struts-default.xml, struts-plugin.xml, struts-config.xml</param-value>
</init-param>
</filter>

2) do the above (1), and in a more or less empty struts-config.xml have an <include /> element, trying to include a second struts config file with the bulk of the config stuff from /WEB-INF/config/, but i seem to not be able to get the include to find the second file despite trying absolute and relative paths, leading and non-leading slash etc.

3) do the above (1), but instead of just struts-config.xml put /WEB-INF/config/struts-config.xml

4) doing the above (1), but have a second <init-param> block and specify the struts-config.xml file there. the first <init-param> block would only have the first two values, struts-default.xml and struts-plugin.xml. i wasn't quite sure what the param-name should be though, and i havent been able to find out what the valid init parameters are for StrutsPrepareAndExecuteFilter.


any help would be appreciated. this really shouldn't be very hard, and it's quite possible that im missing something obvious

thanks!
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Off the top of my head I thought that the S2 config files had to be on the classpath, but I could be mis-remembering. Is it really important for you that they not be on the classpath?
 
jake khan
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I mainly want to have all config files in the one place, eg under /WEB-INF/config/.
I guess I can keep it there, and, as part of the build, add an extra step to copy it to the classes dir.
Cheers,
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, they're all in one place if they're in the classpath, too.
 
jake khan
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes. makes more sense to me to have config files in a config directory, rather than in a java source directory...
i'll fiddle around with a build script and see if i can work it out.
thanks for your feedback
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The thing is that having them on the classpath allows for more versatility, in that JAR files (like plugins, portions of apps, etc.) can contain trivially-loadable config files.
 
straws are for suckers. tiny ads are for attractive people.
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic