Could not find action or result
There is no Action mapped for namespace / and action name Login. - [unknown location]
at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:189)
at org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:61)
at org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)
at com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:475)
at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:395)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
以上是今天我学习struts框架所遇到的问题,按照myeclipse的说法是我没有找到action也即Login。但是我明明写了代码了
struts如下:<?xml version="1.0" encoding="GBK"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="text01" extends="struts-default" >
<action name="Login" class="struts2.action.LoginAction">
<result name="success">/welcome.jsp</result>
<result name="fail">/failLogin.jsp</result>
</action>
</package>
</struts>
web.xml如下:filter>
<filter-name>FilterDispatcher</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>FilterDispatcher</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
其实大家都知道,我的代码没有错,而为什么又要出现这样的错误呢。其实也是我马虎所在:就是我将struts没有加后缀.xml
本来我不想写这个博文的,但是在网上看见很多的前辈都出现了这样或那样的错误,今天我就给大家总结一下经常出现的错误如下:
马虎的:1、将struts写成struct还有没加.xml的,别看问题小,第一次接触的犯这样的错误的大有所在。2、问题出现在namespace上的,我劝大家如果刚接触的话,先不要加namespace,也可以设成namespace=""这样也可以,namespace其实符合小组开发的。3、这个问题太扯,但是是最多的就是拼错了。我写这篇博文的目的不仅是告诉大家写代码如果出错了,尽量自己去找,同时也是告诉自己遇事不要马虎了