How to set up applicationcontext.xml in eclipse

when i put struts.xml in web-inf it shows error ...... when i paste src folder it works fine. (being applicationcontext.xml in web-inf)

(being struts.xml in (src folder or src / resources)) when I put applicationcontext.xml in src folder ......... it says it can't find applicationcontext.xml in web-inf folder. .......... fails.

how to configure so that eclipse can find the struts.xml or applicationcontext.xml path so that wherever I put it it needs to be discovered.

the code in web.xml looks like this.

<filter>
        <filter-name>struts2</filter-name>
        <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
    </filter>
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
</web-app>

      

Thanks everyone.

+3


source to share


2 answers


Configure context parameter in web.xml as shown below:

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value> /WEB-INF/application-context.xml</param-value>
  </context-param>

      



And put your application-context.xml in WEB-INF folder.

+1


source


if you paste the web-inf folder

<context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>/WEB-INF/applicationContext*.xml</param-value>
</context-param>

      

if you paste the src / resource folder

<context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath*:applicationContext*.xml</param-value>
    </context-param>

      

one more thing if you get an error like below after making changes.



http://www.bpjava.net/Struts2_Configuration_Plugin/config-browser/showBeans.action

the solution is given at the end.

or you can do the following.

in struts.xml <constant name="struts.devMode" value="false" />

+2


source







All Articles