Struts 2.2.1 gives There is no Action mapped for namespace / and action name
I've got a simple Struts 2 application that I build and deploy to glassfish with Netbeans. When I point the web browser to http://localhost:8080/Struts2Hello/login.action/ it gives this error:
There is no Action mapped for namespace / and action name .
My action is named "login". Why does it think it is named "."?
(In order to get this far I've also had to add the javassist-3.7.ga to my lib/ directory. I'm not sure why, but that's what others have done to make Struts 2.2 work.)
Here's my web.xml and struts.xml files (yes, the struts.xml gets deployed to WEB-INF/classes):
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>Login.jsp</welcome-file>
</welcome-file-list>
<package name="default" extends="struts-default" namespace="/">
<action n开发者_JS百科ame="login" class="action.LoginAction">
<result name="success">Welcome.jsp</result>
<result name="error">Login.jsp</result>
</action>
</package>
Thanks.
Dean
My problem was that I had the .jsp files in the WEB-INF/ dir instead of one level higher. Strange error message for that problem, though.
In struts.xml(or any other struts config files included), content of mapping is back to the original Servlet/Jsp, i.e. you CAN NOT put .jsp files under WEB-INF. e.g. if the result in struts config file is: Welcome.jsp then you should put Welcome.jsp under the package root, like Web-pages ...WEB-INF ...Welcome.jsp ...menu ......menu.xhtml
More often that not when struts gets the action name wrong even when there's nothing wrong with struts.xml, the problem is that the tag lib definition is missing from the jsp file.
crazy to answer this one after a year, but I had the same problem and I was pretty sure that I had mapped all my actions accurately, but it was showing the same error above....so I just cleaned the project and then ran it again..it worked perfectly fine...give it a try !
I encountered this so many times...so to avoid such kind of things, I just added "../eclipse.exe -clean" to the shortcut icon property....this works and u can forget about getting such kind of errors which is actually not an error....!
精彩评论