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.
当我尝试运行我的Web应用程序时,上面的逻辑抛出FileNoFoundException。任何人都可以告诉我如何读取位于WEB-INF内的配置文件。我已经验证了很多例子,但我找不到合适的解决方案。我怀疑是否可以这样称呼。我在web中给出了我的servlet位置,xml也是。这是我的web.xml代码。
<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
请告诉我,我正在写写法。任何建议将不胜感激
1 个解决方案
#1
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>
#1
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>