0

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

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

(在单词'name'之后,是一个空格)

任何意见将不胜感激。

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

1 回答 1

0

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

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

<action name=""> <result>jsp file path</result></action>
<action name="/"> <result>jsp file path</result></action>
于 2014-02-13T17:24:17.173 回答