Google app engine Struts 2没有为命名空间[/]映射任何操作

Google app engine Struts 2没有为命名空间[/]映射任何操作,google-app-engine,indexing,struts2,namespaces,action-mapping,Google App Engine,Indexing,Struts2,Namespaces,Action Mapping,我正在学习Struts 2以满足项目需求,我遇到了一些问题 以下是本教程的网址: 还有我做的额外工作: 将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:

我正在学习Struts 2以满足项目需求,我遇到了一些问题

以下是本教程的网址:

还有我做的额外工作:

  • 将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>
    
    我得到的不是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>
    
    
    

    与下载时使用的库完全相同


    好的,我知道你的问题

    将struts.xml更改为

      <struts>
           <package name="default" extends="struts-default" namespace="/">
                <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>
    
    
    页面/login.jsp
    pages/welcome_user.jsp
    

    我想这是可行的,因为如果你把struts.xml文件放在根目录下,filterDispatcher会在根文件夹中搜索struts.xml文件。

    @Eleazar我遵循了你在问题中提到的mykong教程链接。就我所看到的教程而言,
    index.html
    没有任何用处<代码>
    文件在应用程序启动时未提及操作时使用

    在第8步,在该教程中,他们提供了
    url
    ,即
    http://localhost:8888/User/Login.action
    您需要运行测试。这和欢迎名单上的文件无关

    更新:


    您之所以会出现此错误,是因为您已将struts2筛选器添加为
    /*
    ,并且您的操作命名空间用于
    /User
    /
    没有操作命名空间。使用namespace=“/”添加name=“default”的包,即
    将解决您的问题。它将命中

    我想,您还没有在struts.xml文件中映射操作名称,请显示您的struts.xml文件。@arvin\u codeHunk您好,根据教程,没有必要将struts映射到index.html否?很抱歉,我想你已经删除了
    web.xml
    文件中的所有内容,上面是web.xml中唯一的内容,因为我看不到到实际查找struts.xml文件的
    filterdispatcher
    的映射。好的,你的struts.xml文件在你的根目录中吗,我是说你把struts.xml文件放在哪里了?我知道,index.jsp不需要操作映射,但是如果您复制粘贴了代码,那么您需要映射驻留在视图中的所有操作。我已经更改了它,但它不起作用。据我所知,您将包名从user更改为default?不过,我试图让在欢迎文件中指向index.jsp起作用。struts.xml在我的根/src folderok中,这是您的url,为什么只显示您的端口名这应该是这样的是的,我可以正常加载,没有问题。但是当我输入时,我试图加载index.jsp,这里是localhost:8888,我不想让我的用户访问我觉得当他们可以访问xxxx.com时,这太过分了。你刚刚错过了要点,如果您使用ide在localhost上运行项目,那么应该是这样的localhost:8888/您的项目名称恐怕我错过了这一点。但是,项目名称为Struts2GoogleAppEngine。加载时,也会出现同样的错误。是的,我知道你来自哪里。但是,我希望在我尝试部署的任何地方都包含一个index.jsp作为“登录”页面。在本例中,是localhost:8888,我希望localhost:8888,或者当我在网站上部署时,首先让它们的根指向我的index.jsp。这就是我试图实现的,但它不允许我实现。好的,然后在struts.xml中定义另一个包,即
    ,在名为user的包之前。不要在里面写任何动作。将index.jsp保存在web内容文件夹中。并运行应用程序。希望您看到index.jsp页面谢谢您的回复,我刚才也尝试过,但仍然会出现错误。):埃利亚扎尔,你完全按照这篇文章写了吗?这篇文章的所有库都有相同的版本吗?如果调用“/”名称空间不可能再出现错误,您将使用/User namespace…@AndreaLigios是的Andrea,您是对的。但这不是问题所在。我可以登陆。行动很好。问题是,我试图在主域中访问index.jsp,就像默认值是index.html时一样,我使用了与教程中所述库完全相同的版本。我将附上第一篇文章中使用的所有库的zip。是的,我紧跟着所有的步骤。如果你尝试一下,我相信你也会犯同样的错误。我在日食艾德朱诺。
      <struts>
           <package name="default" extends="struts-default" namespace="/">
                <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>