加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

java-如何在Eclipse中配置applicationcontext.xml

发布时间:2020-12-15 01:20:57 所属栏目:大数据 来源:网络整理
导读:当我将struts.xml放入web-inf时显示错误当我将src文件夹放入时,它工作正常.(在web-inf中为applicationcontext.xml) 当我将applicationcontext.xml放在src文件夹中时(在(src文件夹或src / resources)中为struts.xml).这就是说无法在web-inf文件夹中找到applic

当我将struts.xml放入web-inf时显示错误……当我将src文件夹放入时,它工作正常.(在web-inf中为applicationcontext.xml)

当我将applicationcontext.xml放在src文件夹中时(在(src文件夹或src / resources)中为struts.xml)…….这就是说无法在web-inf文件夹中找到applicationcontext.xml. ….它无法执行.

我该如何配置以便eclipse可以找到struts.xml或applicationcontext.xml的路径,以便无论我放置在哪里它都应该检测到它.

web.xml中的代码如下.

<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>

谢谢你们.

最佳答案
像下面这样在web.xml中配置context-param:

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

并将您的application-context.xml放在WEB-INF文件夹中.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读