想要把struts.xml放在src/config 下
web.xml配置如下:
<!-- struts2配置 -->
<filter>
<filter-name>cleanup</filter-name>
     <filter-class>
org.apache.struts2.dispatcher.ActionContextCleanUp
     </filter-class>
</filter>
<filter-mapping>
<filter-name>cleanup</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>  
 <filter-name>struts2</filter-name>  
 <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class> 
 <init-param>
               <param-name>config</param-name>
               <param-value>struts-default.xml,struts-plugin.xml,classpath*:config/struts.xml</param-value>
     </init-param>   
</filter> 
一直报:There is no Action mapped for namespace / and action name login.  跪求解决方法,在线等!

解决方案 »

  1.   

    struts2的filterMapping没有
    There is no Action mapped for namespace / and action name login找不到name="login"的action,在确认struts2 FilterMapping存在的情况下,去查看struts.xml吧。
      

  2.   

    <!-- struts2配置 -->
    <filter>
    <filter-name>cleanup</filter-name>
    <filter-class>
    org.apache.struts2.dispatcher.ActionContextCleanUp
    </filter-class>
    </filter>
    <filter-mapping>
    <filter-name>cleanup</filter-name>
    <url-pattern>/*</url-pattern>
    </filter-mapping>
    <filter>  
     <filter-name>struts2</filter-name>  
     <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class> 
     <init-param>
          <param-name>config</param-name>
          <param-value>struts-default.xml,struts-plugin.xml,classpath*:config/struts.xml</param-value>
         </init-param>   
    </filter>  
    <filter-mapping>   
    <filter-name>struts2</filter-name>  
    <url-pattern>/*</url-pattern>  
    </filter-mapping> 
    存在,请帮看看是什么问题?
      

  3.   

    <?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>
    <constant name="struts.objectFactory" value="spring" />
    <constant name="struts.enable.DynamicMethodInvocation" value="false" />
        <constant name="struts.devMode" value="true" />
    <constant name="struts.i18n.encoding" value="UTF-8" />
    <!-- 配置struts2如下 -->
    <package name="MediaCluster" extends="struts-default">

    <!-- 登陆action -->
    <action name="login" class="loginAction" method="login">
    <result name="success">index.jsp</result>
    <result name="input">index.jsp</result>
    </action>
    </package>
    </struts>
      

  4.   

    你贴的web.xml中没有了监听器啊!!struts.xml配置比较简单:
    <action name="user" class="user">
           <result name=" ">/page.jsp</result>
        </action>
    大概就是这个模式!!
      

  5.   


    <action name="login" class="loginAction" method="login">
    class加包名了吗?
      

  6.   

    很有可能是你的struts.xml的路径没找到、
    或者action里面使用了注解了吧??
      

  7.   

    public class LoginAction extends ActionSupport {
    /**
     * 
     */
    private static final long serialVersionUID = 1L;
    private String userName;
    private String password; public String getUserName() {
    return userName;
    } public void setUserName(String userName) {
    this.userName = userName;
    } public String getPassword() {
    return password;
    } public void setPassword(String password) {
    this.password = password;
    } public String login() {
    String str1 = userName;
    String str2 = password;
    System.out.println(str1);
    System.out.println(str2);
    return "success";
    }}
      

  8.   

    <action name="login" class="loginAction" method="login">loginAction的路径是完整路径么?
      

  9.   

    loginAction是spring 中的一个对象,把struts托管给spring了。
    <constant name="struts.objectFactory" value="spring" />
      

  10.   

    <!-- struts2配置 -->
    <filter>
       <filter-name>struts-cleanup</filter-name>
       <filter-class>org.apache.struts2.dispatcher.ActionContextCleanUp</filter-class>
         </filter>
      <filter-mapping>
        <filter-name>struts-cleanup</filter-name>
        <url-pattern>/*</url-pattern>
      </filter-mapping>
    <filter>
    <filter-name>struts2</filter-name>
    <filter-class>
    org.apache.struts2.dispatcher.FilterDispatcher
    </filter-class>
    <init-param>
    <param-name>config</param-name>
    <param-value>struts-default.xml,struts-plugin.xml,config/struts.xml</param-value>
    </init-param>
    </filter>

    <filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>*.action</url-pattern>
    </filter-mapping>已解决,和大家分享一下。