【发布时间】:2013-02-01 06:29:16
【问题描述】:
我正在为项目需求学习 Struts 2,但遇到了一些问题。
按照本教程在:
http://www.mkyong.com/google-app-engine/google-app-engine-struts-2-example/
以及我所做的额外工作:
- 将 index.jsp 添加到 war 文件夹中
-
将 web.xml 更改为
<?xml version="1.0" encoding="utf-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5"> <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> <listener> <listener-class>com.mkyong.listener.Struts2ListenerOnGAE</listener-class> </listener> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> </web-app>
现在,当我重建和加载时
http://localhost:8888
而不是看到我应该在我的 index.jsp 中包含的内容,我得到了一个
Error 404 There is no Action mapped for namespace [/] and action name [] associated with context path [].
有人能指出我正确的方向吗?我在 SO 中看到了一些其他类似的问题,但他们的解决方案不适用于 Struts 2 + GAE 的这个特定示例。
我的 struts.xml
<struts>
<package name="user" namespace="/User" extends="struts-default">
<action name="Login">
<result>pages/login.jsp</result>
</action>
<action name="Welcome" class="com.mkyong.user.action.WelcomeUserAction">
<result name="SUCCESS">pages/welcome_user.jsp</result>
</action>
</package>
</struts>
文件夹结构
我不能发布图片所以,http://i.imgur.com/KSPmaMr.png
用于下载的库完全相同
【问题讨论】:
-
我猜,你没有在你的 struts.xml 文件中映射动作名称,请给我你的 struts.xml 文件。
-
@arvin_codeHunk 嗨,根据教程,不需要将 struts 映射到 index.html 吗?抱歉,这是新手。
-
我猜你已经从
web.xml文件中删除了所有内容,上面是 web.xml 中的唯一内容,因为我看不到实际查找 struts.xml 文件的filterdispatcher的映射. -
好的,您的 struts.xml 文件是否在您的根目录中,我的意思是您放置 struts.xml 文件的位置?
-
我知道,index.jsp 不需要 action_mapping,但是如果您复制粘贴了代码,那么您需要映射驻留在视图中的所有操作
标签: google-app-engine indexing struts2 namespaces action-mapping