<s:form name="loginform" action="login" >
  <s:textfield name="username" label="用户名" />
  <s:textfield name="password" label="密     码" />
  <s:submit value="登录" />
</s:form><package name="default" namespace="/" extends="struts-default">
 
     <action name="login" class="loginAction" >
      <result name="success">/success.jsp</result>
      <result name="error">/error.jsp</result>
     </action></package>
警告: No configuration found for the specified action: 'login' in namespace: ''.根据网友的理论:先搜索根命名空间"/",再搜索默认命名空间"",找不到就出警告但是我明明把package放在namespace="/" 下了,难道这样做没用?
又有网友说
在JSP页面中<s:form >里边加个namespace="/"就行了, 这个/是指的绝对路径,所以当然可以是任意的。比如说"/login", "/abc", "/abc/def"等等。在<s:form>里的action="slkdfjksfdj"中里边不用加上后缀.action 。 请大家详解

解决方案 »

  1.   


    <s:form name="loginform" action="/login" >
    ......
    ....
      

  2.   

    <s:form name="loginform" action="login.action" >
      

  3.   

    嗯。要加上.action。当然你也可以在web.xml文件中更改你要拦截的后缀名。比如<filter>
    <filter-name>struts2</filter-name>
    <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
    </filter>
    <filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>*.action</url-pattern>
    </filter-mapping>你要是把*.action 改成 *.xxx你的页面上就可以写login.xxx了
      

  4.   

    struts 标签 ,可以不加.action,
      

  5.   

    访问后缀看在web.xml中怎么配的
      

  6.   

     可以这样配<url-pattern>/*</url-pattern>
      

  7.   

    在JSP页面中<s:form >里边加个namespace="/"就行了
      

  8.   

    在web.xml中把<url-pattern>*.action</url-pattern改为<url-pattern>/*</url-pattern>
      

  9.   

    你在jsp form没定义的话 他会找默认的命名""  
    你想不出警告的话  要么在form和struts。xml同时定义命名空间  
    要么同时不定义命名空间