0
ApplicationContext context=new ClassPathXmlApplicationContext("/WEB-INF/spring/DispatcherServlet-servlet.xml");

above logic throwing FileNoFoundException while i try to run my web Application. can anybody tell me how to read the configuration file which is located inside WEB-INF. i have verified so many examples but i could not found the proper solution .here my doubt is can we call like this or not. i given my servlet location in web,xml also. here is my web.xml code.

<servlet>
        <servlet-name>DispatcherServlet</servlet-name>
        <servlet-class>
            org.springframework.web.servlet.DispatcherServlet
        </servlet-class>
         <init-param>
        <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/spring/DispatcherServlet-servlet.xml</param-value>
    </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

please tell me i am doing write approach or not. any suggestions will appreciate

suri
  • 415
  • 1
  • 9
  • 22
  • You shouldn't be even loading the context yourself! So I would say your code is flawed, if you need a bean use dependency injection, don't recreate the context... – M. Deinum Mar 01 '16 at 09:23
  • yes i need a bean i am updating my code but here i need job id. can you please see this link i have one query that's my i asked this question http://stackoverflow.com/questions/35700632/how-to-run-multiple-jobs-using-spring-batch?noredirect=1#comment59109978_35700632 – suri Mar 01 '16 at 09:31

1 Answers1

0
<servlet>
    <servlet-name>appServlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>appServlet</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>
Nandu cg
  • 74
  • 1
  • 10