【问题标题】:welcome-file tag seems to be ignored欢迎文件标签似乎被忽略了
【发布时间】:2011-07-22 18:59:57
【问题描述】:

基于 struts2 appfuse maven 项目我正在尝试设置我的个人 HelloWorld struts2 maven 项目。

我在 pom.xml、web.xml 和 struts.xml 文件中简化了很多东西。结果,似乎<welcome-file-list><welcome-file> 标签没有被考虑在内,当我点击http://localhost:8080/ 时,我的文件index.jsp 没有加载。 出现下一条错误消息: 没有为命名空间 / 和操作名称映射操作。

(在“姓名”一词之后,是一个空格)

我们将不胜感激。

在 web.xml 中:

    <filter>
        <filter-name>struts2</filter-name>
        <filter-class>
             org.apache.struts2.dispatcher.FilterDispatcher
            </filter-class>
    </filter>

    <filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

<listener>
    <listener-class>
       org.springframework.web.context.ContextLoaderListener
    </listener-class>
</listener>

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

struts.xml 内部:

<constant name="struts.devMode" value="true" />
<package name="default" namespace="/" extends="struts-default"> 
    <action name="Menu">
        <result>/menu/Menu.jsp</result>
    </action>
</package>

【问题讨论】:

  • 你能不能只显示错误控制台输出
  • # Messages: 没有为命名空间 / 和操作名称映射操作。 Stacktraces 没有为命名空间 / 和操作名称映射操作。 - [未知位置] com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:178)
  • 好的..这意味着您的映射以及您调用操作的位置存在一些问题。您能否向我们展示您调用操作“菜单”的 jsp 文件
  • 抱歉,暂时忘记了菜单操作和其他内容。正如我认为的那样,问题是前一步;我只想在没有 Struts2 机制干预的情况下加载我的简单 index.jsp 欢迎文件。 (在 index.jsp 中,我只放了经典的“Hello world!”)
  • 好的!删除所有内容,只需创建一个动态 Web 应用程序并检查索引页面是否即将到来..您提到的问题很明显 struts2 无法将操作映射到任何位置

标签: struts2 maven appfuse


【解决方案1】:

似乎 struts2 过滤器正在尝试查找名称为空“”或“/”路径的操作。所以不会到达欢迎列表。 struts.xml 中也没有“”和“/”的条目。就是这个错误。

所以在 struts.xml 中添加以下条目将解决此问题..

<action name=""> <result>jsp file path</result></action>
<action name="/"> <result>jsp file path</result></action>

【讨论】:

    猜你喜欢
    • 2021-10-28
    • 2016-09-30
    • 2012-03-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-05
    • 2012-03-08
    • 2015-12-11
    相关资源
    最近更新 更多