这两天用ecplise新建一个struts2的项目,但是访问的时候一直报错,
警告: Could not find action or result
There is no Action mapped for namespace [/] and action name [login] associated with context path [/migo]. - [unknown location]
at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:185)
at org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:63)
网上查看好多解决方法,但是都没有解决,实在找不出错误的地方,请高人指点。这个是项目目录
这个是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_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>Migo</display-name>
  
  <filter>  
        <!-- 配置Struts2核心Filter的名字 -->  
        <filter-name>struts2</filter-name>  
        <!-- 配置Struts2核心Filter的实现类 -->  
        <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>  
    </filter>  
    <!-- 配置Filter拦截的URL -->  
    <filter-mapping>  
        <!-- 配置Struts2的核心FilterDispatcher拦截所有用户请求 -->  
        <filter-name>struts2</filter-name>  
        <url-pattern>/*</url-pattern>  
    </filter-mapping>  
    
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
  </welcome-file-list>
</web-app>这个是struts.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
        "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
        "http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
    <!-- struts2的action必须放在一个指定的包空间下定义 -->
    <package name="default" extends="struts-default">
    <!-- 定义处理请求URL为login.action的Action -->
        <action name="login" class="sdsdmigo.login.action.LoginAction">
        <!-- 定义处理结果字符串和资源之间的映射关系 -->
            <result name="success">/success.jsp</result>
            <result name="error">/error.jsp</result>
        </action>
    </package>
</struts>这个是项目启动信息
2012-12-24 16:21:23 org.apache.catalina.core.AprLifecycleListener init
信息: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: E:\Program Files\Java\jdk1.6.0_32\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;E:\Program Files\Java\jdk1.6.0_32\jre\bin;C:/Program Files/Java/jre7/bin/client;C:/Program Files/Java/jre7/bin;C:/Program Files/Java/jre7/lib/i386;e:\oracle\product\10.2.0\db_1\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\SSH Communications Security\SSH Secure Shell;E:\eclipse;;.
2012-12-24 16:21:24 org.apache.coyote.http11.Http11Protocol init
信息: Initializing Coyote HTTP/1.1 on http-8080
2012-12-24 16:21:24 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 709 ms
2012-12-24 16:21:24 org.apache.catalina.core.StandardService start
信息: Starting service Catalina
2012-12-24 16:21:24 org.apache.catalina.core.StandardEngine start
信息: Starting Servlet Engine: Apache Tomcat/6.0.35
2012-12-24 16:21:24 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
信息: Parsing configuration file [struts-default.xml]
2012-12-24 16:21:24 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
信息: Unable to locate configuration files of the name struts-plugin.xml, skipping
2012-12-24 16:21:24 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
信息: Parsing configuration file [struts-plugin.xml]
2012-12-24 16:21:24 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
信息: Unable to locate configuration files of the name struts.xml, skipping
2012-12-24 16:21:24 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
信息: Parsing configuration file [struts.xml]
2012-12-24 16:21:24 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
信息: Choosing bean (struts) for (com.opensymphony.xwork2.ObjectFactory)
2012-12-24 16:21:24 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
信息: Choosing bean (struts) for (com.opensymphony.xwork2.FileManagerFactory)
2012-12-24 16:21:24 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
信息: Choosing bean (struts) for (com.opensymphony.xwork2.conversion.impl.XWorkConverter)
2012-12-24 16:21:24 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
信息: Choosing bean (struts) for (com.opensymphony.xwork2.TextProvider)
2012-12-24 16:21:24 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
信息: Choosing bean (struts) for (com.opensymphony.xwork2.LocaleProvider)
2012-12-24 16:21:24 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
信息: Choosing bean (struts) for (com.opensymphony.xwork2.ActionProxyFactory)
2012-12-24 16:21:24 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
信息: Choosing bean (struts) for (com.opensymphony.xwork2.conversion.ObjectTypeDeterminer)
2012-12-24 16:21:24 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
信息: Choosing bean (struts) for (org.apache.struts2.dispatcher.mapper.ActionMapper)
2012-12-24 16:21:24 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
信息: Choosing bean (jakarta) for (org.apache.struts2.dispatcher.multipart.MultiPartRequest)
2012-12-24 16:21:24 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
信息: Choosing bean (struts) for (org.apache.struts2.views.freeer.FreeerManager)
2012-12-24 16:21:24 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
信息: Choosing bean (struts) for (org.apache.struts2.components.UrlRenderer)
2012-12-24 16:21:24 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
信息: Choosing bean (struts) for (com.opensymphony.xwork2.validator.ActionValidatorManager)
2012-12-24 16:21:24 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
信息: Choosing bean (struts) for (com.opensymphony.xwork2.util.ValueStackFactory)
2012-12-24 16:21:24 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
信息: Choosing bean (struts) for (com.opensymphony.xwork2.util.reflection.ReflectionProvider)
2012-12-24 16:21:24 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
信息: Choosing bean (struts) for (com.opensymphony.xwork2.util.reflection.ReflectionContextFactory)
2012-12-24 16:21:24 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
信息: Choosing bean (struts) for (com.opensymphony.xwork2.util.PatternMatcher)
2012-12-24 16:21:24 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
信息: Choosing bean (struts) for (org.apache.struts2.dispatcher.StaticContentLoader)
2012-12-24 16:21:24 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
信息: Choosing bean (struts) for (com.opensymphony.xwork2.UnknownHandlerManager)
2012-12-24 16:21:24 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
信息: Choosing bean (struts) for (org.apache.struts2.views.util.UrlHelper)
2012-12-24 16:21:24 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
信息: Choosing bean (struts) for (com.opensymphony.xwork2.conversion.impl.CollectionConverter)
2012-12-24 16:21:24 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
信息: Choosing bean (struts) for (com.opensymphony.xwork2.conversion.impl.ArrayConverter)
2012-12-24 16:21:24 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
信息: Choosing bean (struts) for (com.opensymphony.xwork2.conversion.impl.DateConverter)
2012-12-24 16:21:25 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
信息: Choosing bean (struts) for (com.opensymphony.xwork2.conversion.impl.NumberConverter)
2012-12-24 16:21:25 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
信息: Choosing bean (struts) for (com.opensymphony.xwork2.conversion.impl.StringConverter)
2012-12-24 16:21:25 org.apache.catalina.startup.HostConfig deployDescriptor
信息: Deploying configuration descriptor host-manager.xml
2012-12-24 16:21:25 org.apache.catalina.startup.HostConfig deployDescriptor
信息: Deploying configuration descriptor manager.xml
2012-12-24 16:21:25 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory docs
2012-12-24 16:21:25 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory examples
2012-12-24 16:21:25 org.apache.catalina.core.ApplicationContext log
信息: ContextListener: contextInitialized()
2012-12-24 16:21:25 org.apache.catalina.core.ApplicationContext log
信息: SessionListener: contextInitialized()
2012-12-24 16:21:25 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory ROOT
2012-12-24 16:21:25 org.apache.coyote.http11.Http11Protocol start
信息: Starting Coyote HTTP/1.1 on http-8080
2012-12-24 16:21:25 org.apache.jk.common.ChannelSocket init
信息: JK: ajp13 listening on /0.0.0.0:8009
2012-12-24 16:21:25 org.apache.jk.server.JkMain start
信息: Jk running ID=0 time=0/23  config=null
2012-12-24 16:21:25 org.apache.catalina.startup.Catalina start
信息: Server startup in 1833 ms

解决方案 »

  1.   


    http://localhost:8080/migo/
    http://localhost:8080/migo/login.action
    这两个都报错的 
      

  2.   

    <action name="login" class="sdsdmigo.login.action.LoginAction">
    你这个class写错了吧?多了sdsd?
      

  3.   

    namespace  命名空间问题
      

  4.   

    很明显的错误:There is no Action mapped for namespace [/] and action name [login]  <action name="login" class="sdsdmigo.login.action.LoginAction">
     这里错了,都没看见你有sdsdmigo这个目录,应该是migo
     
      

  5.   


    这个是我故意写错的,但是启动的时候竟然没有报错,所以我一直觉得是我的struts.xml文件没有加载成功。
      

  6.   


    这个是我故意写错的,但是启动的时候竟然没有报错,所以我一直觉得是我的struts.xml文件没有加载成功。
      

  7.   

    index.html  ______________-index.jsp
      

  8.   


    在jsp的action中的请求上写个name属性,可以从网上看看相关的代码分析
      

  9.   

    看这里貌似是加载了struts.xml了2012-12-24 16:21:24 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
    信息: Unable to locate configuration files of the name struts.xml, skipping
    2012-12-24 16:21:24 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
    信息: Parsing configuration file [struts.xml]为了确认,可以试着其它改法,比如将struts.xml中根节点改名
      

  10.   


    只是访问一个url报错,又不是jsp提交过去的,所以跟jsp没有关系。
      

  11.   

    原来是发布的路径不对,默认的output路径是eclipse设置的built/classess,改成项目的WebContent/WEB-INF/classess就可以了。
      

  12.   

    如果他报错可以更细化一点就好了no action found in WebContent/WEB-INF/classess for namespace [/] and action name [login] associated with context path [/migo].