-
Feb 8th, 2006, 06:04 AM
#1
How to access resources in the application root
Hi all,
I have little problem. I need to access resources (any_files.xml), located in .../tomcat/webapps/MyApplication/*. Now I am using classloader to load resources placed in MyApplication/WEB-INF/classes/config/. I need some object which works with ServletContext, but I can't still find anything suitable for me. I need to write (anywhere in code) something like: ContextUtils.getServletContext()
Can anyone help me?
Thank you, James
-
Feb 8th, 2006, 10:25 AM
#2
I have discovered solution. It is different when you are starting application context in web container or starting in Junit TestCase(AbstractDependencyInjectionSpringContextT ests). When starting in the web container it is simple:
servletContext = ((WebApplicationContext) applicationContext).getServletContext();
url = servletContext.getResource(sourceFile);
When testing application context is instance of ClassPathXmlApplicationContext class
and resources are loaded from classpath.
That's all.
James
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules