<bdo id='bRWzH'></bdo><ul id='bRWzH'></ul>
<legend id='bRWzH'><style id='bRWzH'><dir id='bRWzH'><q id='bRWzH'></q></dir></style></legend>

        <small id='bRWzH'></small><noframes id='bRWzH'>

      1. <i id='bRWzH'><tr id='bRWzH'><dt id='bRWzH'><q id='bRWzH'><span id='bRWzH'><b id='bRWzH'><form id='bRWzH'><ins id='bRWzH'></ins><ul id='bRWzH'></ul><sub id='bRWzH'></sub></form><legend id='bRWzH'></legend><bdo id='bRWzH'><pre id='bRWzH'><center id='bRWzH'></center></pre></bdo></b><th id='bRWzH'></th></span></q></dt></tr></i><div id='bRWzH'><tfoot id='bRWzH'></tfoot><dl id='bRWzH'><fieldset id='bRWzH'></fieldset></dl></div>
        <tfoot id='bRWzH'></tfoot>

        更改多模块 Maven Web 项目的 struts.xml 文件名

        时间:2023-09-25
      2. <legend id='G2JaL'><style id='G2JaL'><dir id='G2JaL'><q id='G2JaL'></q></dir></style></legend>
          • <tfoot id='G2JaL'></tfoot>

            <i id='G2JaL'><tr id='G2JaL'><dt id='G2JaL'><q id='G2JaL'><span id='G2JaL'><b id='G2JaL'><form id='G2JaL'><ins id='G2JaL'></ins><ul id='G2JaL'></ul><sub id='G2JaL'></sub></form><legend id='G2JaL'></legend><bdo id='G2JaL'><pre id='G2JaL'><center id='G2JaL'></center></pre></bdo></b><th id='G2JaL'></th></span></q></dt></tr></i><div id='G2JaL'><tfoot id='G2JaL'></tfoot><dl id='G2JaL'><fieldset id='G2JaL'></fieldset></dl></div>

            <small id='G2JaL'></small><noframes id='G2JaL'>

                  <tbody id='G2JaL'></tbody>
                • <bdo id='G2JaL'></bdo><ul id='G2JaL'></ul>

                  本文介绍了更改多模块 Maven Web 项目的 struts.xml 文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个包含多个模块的 Maven 项目.在四个模块中,其中两个是 Web 模块.

                  I have a Maven project with multiple modules. Out of four modules, two of them are web modules.

                  这是结构.

                  MyProject
                     |
                     |__ api
                     |
                     |__ commons
                     |
                     |__ web_child
                     |
                     |__ web_main
                  

                  web_main 模块是主要模块,它也可以包含 web_child 模块.

                  web_main module is the main one and it can include web_child module also.

                  web_child模块结构是

                   web_child
                       |
                       |__ src/main/java //java action classes and all
                       |__ src/main/resources
                       |    |__ struts-config.xml
                       |
                       |__ WEB-INF
                            |__ JSP Pages
                  

                  web_main模块结构是

                   web_main
                       |
                       |__ src/main/java //java action classes and all
                       |__ src/main/resources
                       |    |__ struts.xml
                       |
                       |__ WEB-INF
                            |__ JSP Pages
                  

                  两个模块都是war.

                  web-main 依赖于所有模块,web-child 依赖于前两个(API 和公共)模块.

                  web-main depends on all the modules, and web-child depends on first two (API & commons) modules.

                  web-mainpom.xml 中,我正在添加 web-child 的依赖项,它会自动添加其他两个罐子.

                  in web-main's pom.xml, I'm adding the dependency for web-child and it will automatically add other two jars.

                  主模块 web-main 在服务器上完美运行.

                  The main module web-main is running perfectly on server.

                  但是当我尝试单独运行 web-child 模块时,它会显示类似

                  But when I am trying to run the web-child module alone, it is showing error like

                  There is no Action mapped for namespace [/] and action name [childMenu] associated with context path ...  
                  

                  因为它没有取struts-config.xml

                  当我将文件重命名为 struts.xml 时,web-child 工作正常.但是那个时候主模块没有运行.

                  When I am renaming the file to struts.xml, web-child is working fine. But that time main module is not running.

                  所以我想将子模块中的 struts.xml 重命名为 struts-config.xml 并且我需要明确指定它.

                  So I want to rename the struts.xml in child module to struts-config.xml and I need to specify it explicitly.

                  我正在使用 Struts2.但是我在 web.xml 中尝试了以下内容,显然它不起作用

                  I am using Struts2. But I have tried the following in web.xml and obviously it didn't work

                  <servlet>
                      <servlet-name>action</servlet-name>
                      <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
                      <init-param>
                          <param-name>config</param-name>
                          <param-value>../resources/struts-config.xml</param-value>
                      </init-param>
                    </servlet>
                  

                  如何解决这个问题?

                  更新 1

                  我在我的 web-child web.xml 中添加了以下内容

                  Hi, I added following in my web-child web.xml

                  <filter>
                      <filter-name>struts2</filter-name>
                      <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
                      <init-param>
                          <param-name>config</param-name>
                          <param-value>struts-config.xml</param-value>
                      </init-param>
                  </filter>
                  

                  我得到以下异常.我需要添加任何依赖项吗?

                  And I am getting following exception. Do I need to add any dependency?

                  SEVERE: Exception starting filter struts2
                  Unable to load configuration. - [unknown location]
                      at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:483)
                      at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:74)
                      at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:51)
                      at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:281)
                      at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:262)
                      at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:107)
                      at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4775)
                      at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5452)
                      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
                      at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
                      at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
                      at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
                      at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:976)
                      at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1653)
                      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
                      at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
                      at java.util.concurrent.FutureTask.run(FutureTask.java:166)
                      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
                      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
                      at java.lang.Thread.run(Thread.java:724)
                  Caused by: Unable to load configuration. - [unknown location]
                      at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:71)
                      at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:429)
                      at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:471)
                      ... 19 more
                  Caused by: Cannot locate the chosen ObjectFactory implementation: spring - [unknown location]
                      at org.apache.struts2.config.BeanSelectionProvider.alias(BeanSelectionProvider.java:391)
                      at org.apache.struts2.config.BeanSelectionProvider.alias(BeanSelectionProvider.java:362)
                      at org.apache.struts2.config.BeanSelectionProvider.register(BeanSelectionProvider.java:288)
                      at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:215)
                      at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:68)
                      ... 21 more
                  

                  推荐答案

                  在struts过滤器初始化参数中明确指定配置文件.

                  Specify explicitly config file in the struts filter initialization parameter.

                  <filter>
                      <filter-name>struts2</filter-name>
                      <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
                      <init-param>
                          <param-name>config</param-name>
                          <param-value>struts.xml,struts-config.xml,struts-default.xml,struts-plugin.xml</param-value>
                      </init-param>
                  </filter>
                  

                  这篇关于更改多模块 Maven Web 项目的 struts.xml 文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何验证使用 Struts2 JSON 插件发送的 JSON 而不抛出异常 下一篇:使用命名约定插件拒绝直接访问 Struts2 中的 JSP 文件

                  相关文章

                    <bdo id='zuFDz'></bdo><ul id='zuFDz'></ul>
                • <tfoot id='zuFDz'></tfoot>
                • <small id='zuFDz'></small><noframes id='zuFDz'>

                  <legend id='zuFDz'><style id='zuFDz'><dir id='zuFDz'><q id='zuFDz'></q></dir></style></legend>

                      <i id='zuFDz'><tr id='zuFDz'><dt id='zuFDz'><q id='zuFDz'><span id='zuFDz'><b id='zuFDz'><form id='zuFDz'><ins id='zuFDz'></ins><ul id='zuFDz'></ul><sub id='zuFDz'></sub></form><legend id='zuFDz'></legend><bdo id='zuFDz'><pre id='zuFDz'><center id='zuFDz'></center></pre></bdo></b><th id='zuFDz'></th></span></q></dt></tr></i><div id='zuFDz'><tfoot id='zuFDz'></tfoot><dl id='zuFDz'><fieldset id='zuFDz'></fieldset></dl></div>