问题:No configuration found for the specified action: 'login' in namespace: '/struts'. Form action defaulting to 'action' attribute's literal value.
上网找了很多,但没个能解决的。急........弄了很久很久了
代码:
JSP页面:
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<s:form action="login" namespace="/struts">
<s:textfield name="name" label="账号"/>
<s:password name="password" label="用户密码"/>
<s:password name="password2" label="确认密码"/>
<s:radio name="sex" label="性别"
list="{'男','女'}" value="'男'"
/>
<s:textfield name="birth" label="出生日期"/>
<s:textfield name="email" label="电子邮箱"/>
<s:submit value="注册"/>
</s:form>
</body>
</html>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>
    <constant name="struts.enable.DynamicMethodInvocation" value="false" />
    <constant name="struts.devMode" value="false" />
    
    <package name="struts"  extends="struts-default" namespace="/struts">
<action name="/login.action" class="struts.RegisterAction">
            <result name="success">success.jsp</result>
<result name="error">error.jsp</result>
<result name="input">register.jsp</result>
</action>
    </package>
</struts>web-xml 文档
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_9" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <display-name>last</display-name>
<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,../struts-configs/struts.xml </param-value>
         </init-param>        <init-param>
        <param-name>actionPackages</param-name>
        <param-value>org.crazyjava.auction.action</param-value>
        </init-param>
 </filter>
 <filter-mapping>
          <filter-name>struts2</filter-name>
          <url-pattern>/*</url-pattern>
 </filter-mapping>
</web-app>最后问下,struts-xml是不是要放在web-inf的src文件夹下

解决方案 »

  1.   

    No configuration found for the specified action: 'login' in namespace: '/struts'. Form action defaulting to 'action' attribute's literal value.
    在命名空间中没有定义login的返回页面<package name="struts" extends="struts-default" namespace="/struts">
    <action name="/login.action" class="struts.RegisterAction">
      <result name="login">success.jsp</result>
    <result name="error">error.jsp</result>
    <result name="input">register.jsp</result>
    </action>
      

  2.   

    <package name="struts" extends="struts-default" namespace="/struts">
    <action name="/login.action" class="struts.RegisterAction">
      <result name="login">success.jsp</result>
    <result name="error">error.jsp</result>
    <result name="input">register.jsp</result>
    </action>
      

  3.   

    不行,还会出现警告和错误
    警告: Could not find action or result
    There is no Action mapped for namespace / and action name login. - [unknown location]
      

  4.   

    <action name="/login.action" class="struts.RegisterAction">
    为什么要用/login.action呢,直接/login就行了。
      

  5.   

    四楼说得对,还有,<package name="struts" extends="struts-default" namespace="/struts">这里的namespace还想不用“/”吧??
      

  6.   

    还是不行!
    会不会和我放struts的位置有关
      

  7.   

    我也是struts2的新人 第一点你把jsp中的namespace去了 第二<action name="/login.action" class="struts.RegisterAction">
     改成name=“login” 就行 还有一点就是把struts.xml方在项目的src下(classpath)  \
    第四点 <param-value>struts-default.xml,struts-plugin.xml,../struts-configs/struts.xml </param-value> 这里struts-default.xml struts-plugin.xml不要在这里加载 因为你自定义的struts.xml已经继承了struts-default.xml就会去加载struts-core.jar中的struts-default.xml
    struts-plugin.xml也会在tomcat启动的时候加载 
      但是struts-plugin.xml不知道是dispather的时候加载还是在加载struts-default.xml的时候就加载了
      

  8.   

    No configuration found for the specified action: 'login' in namespace: '/struts'
    在/struts的路径下没有找到,名字叫login的action
    <package name="struts" extends="struts-default" namespace="/struts">
    namespace="/struts" 这样配置的package只能接受/struts路径下的请求第一种解决方案:
          <package name="struts" extends="struts-default" namespace="/struts">
    改成:<package name="struts" extends="struts-default" namespace="/">
    第二种解决方案:
    在webroot下建立个struts文件夹,然后把那个jsp页面放入进去
    OK搞定,还不快去试试
      

  9.   

    谢谢你搞定!我照你第四点的话做成功了。不过有点奇怪,我把工程导出来在另外一个“Workspace”运行就出错了。而且连jsp页面都运行不了。很怪!web-xml的配置肯定还有点问题的。吃完饭再仔细研究下
      

  10.   

    你的方法我也试了,不过还是不行!可能是web-xml的配置有问题吧!
      

  11.   

    顺便问下,在配置struts-xml文件时,是不是要指定namespaace比较好。我之前都没指定的