【问题标题】:Welcome Message in Struts 2 running in Google App Engine在 Google App Engine 中运行的 Struts 2 中的欢迎消息
【发布时间】:2012-05-03 23:16:03
【问题描述】:

我在 web.xml 中有以下几行

<welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
</welcome-file-list>

但是当我访问http://localhost:8888 时收到以下错误:

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

不是重定向到index.jsp吗?如何使欢迎文件工作?

【问题讨论】:

    标签: google-app-engine struts2 action-mapping


    【解决方案1】:

    运行服务器后,它正在搜索一个动作。 您应该在 struts.xml 中有一个映射到 jsp 文件的操作

    在您的 web.xml 中添加以下内容

     <filter>
        <filter-name>struts2</filter-name>
        <filter-class>
           org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
        </filter-class>
      </filter>
      <filter-mapping>
         <filter-name>struts2</filter-name>
         <url-pattern>/*</url-pattern>
      </filter-mapping>
    

    【讨论】:

      【解决方案2】:

      我认为您已经正确配置了欢迎文件。错误消息看起来像一个struts 错误消息。看起来你有一个struts配置问题。检查 struts.xml 文件中的操作类配置。

      【讨论】:

      • 表示动作名称[],表示动作名称为空?
      【解决方案3】:

      请编辑您的struts.xml 并将此操作作为最后一个操作输入(仅在所有操作之后作为默认操作)。

      <action name="*">
          <result type="redirectAction">
          <param name="actionName">Home.action</param>
          </result>
      </action>
      

      现在这必须是最后一个操作,它将像您的应用程序的默认操作一样工作。如果没有找到任何已配置的操作,您的应用程序将被重定向到此操作。

      【讨论】:

        【解决方案4】:

        将以下空白操作添加到“/”包命名空间中的 struts.xml 文件中,当您仅尝试访问您的 url(如 appid.app.com)时,它将显示 index.html 并且不会显示错误。通常它会添加一个空白动作,应用引擎会将空白动作重定向到您的欢迎文件。

            <action name="" class="com.candi.actions.Dashboard" method="noAction">
                <result name="success">index.jsp</result>
            </action>
        

        让我们进一步解释。只需通过提供空白“”作为您的操作名称来添加空白操作,并将您的结果重定向到 index.php,这将解决您的问题。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2021-01-25
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2021-12-24
          • 2021-08-17
          相关资源
          最近更新 更多