【发布时间】: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 无法将操作映射到任何位置