日期:2014-05-17  浏览次数:20766 次

警告: Could not find action or result 什么原因?
2012-9-23 14:58:11 com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn
警告: Could not find action or result
There is no Action mapped for namespace [/] and action name [login] associated with context path [/struts2]. - [unknown location]
at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:185)
at org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:63)


>>>>>>>>>>>>>>>>>>>>>>struts2.xml>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
<package name="struts2" extends="struts-default">
<action name="login" class="zhengjianbo.LoginAction">
<result name="success">/result.jsp</result>
</action>

</package>
>>>>>>>>>>>>>>>>>>web.xml>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
<web-app version="2.5" 
xmlns="http://java.sun.com/xml/ns/javaee" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
  
  <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>
  
</web-app>
>>>>>>>>>>>>>>>>>>>>login.jsp>>>>>>>>>>>>>>>
<form action="login" >
  username:<input type="text" name="username"><br>
  password:<input type="password" name="password"><br>
  <input type="submit" value="submit">
   
   
  </form>
>>>>>>>>>>>>>>>>>result.jsp>>>>>>>>>>>>>>
<body>
 
username:${requestScope.username }<br>
password:${requestScope.password }

</body>
 


------解决方案--------------------
探讨

加上这个试试
<package name="struts2" extends="struts-default" namespace="/">

------解决方案--------------------
<form action="login.action" >
username:<input type="text" name="username"><br>
password:<input type="password" name="password"><br>
<input type="submit" value="submit">
 
 
</form>
表单方法应该是这么写的。
------解决方案--------------------
探讨

引用:

引用:

加上这个试试
<package name="struts2" extends="struts-default" namespace="/">


如果这样不行那就:
struts.xml