错误There is no Action mapped for namespace / and action name—Struts2

Struts2出现错误,总是提示"There is no Action mapped for namespace / and action
name"的错误。

错误代码如下:


09:36:13,515 WARN  [Dispatcher] Could not find action or result
There is no Action mapped for namespace [/] and action name [css] associated with context path [/ChinaUnicom]. - [unknown location]
at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:185)
at org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:63)
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:534)
at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
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:127)
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:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:619)

上网查询后发现这是一个初学者经常碰到的问题,导致错误的原因主要有两种。总结如下:

1.struts.xml文件错误。这种错误又分为以下几种:

1.1struts.xml文件名错误。一定要注意拼写问题;

1.2struts.xml文件放置路径错误。一定要将此文件放置在src目录下。编译成功后,要确认是否编译到classes目录中;

1.3struts.xml文件内容错误。下面给出一个正确的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>
<package name="default" namespace="/" extends="struts-default">
<action name="login" class="com.wanggc.struts2.sample.Struts2Action">
<result name="success">/jsp/result.jsp</result>
</action>
</package>
</struts>

2.如果排除了struts.xml文件的问题,还有一种可能就是,在web.xml文件中的<welcome-file>信息中是否配置了自己工程的启动页面。如果没有配置,地址栏中要输入完成的url,如:http://localhost:8080/Struts2Sample/jsp/login.jsp,后面的资源详细信息不输入的时候也会报这个错误,我就是栽在这个问题上的(^_^)。

错误There is no Action mapped for namespace / and action
name—Struts2

时间: 2024-08-03 11:02:16

错误There is no Action mapped for namespace / and action name—Struts2的相关文章

关于Struts2中的错误:例如There is no Action mapped for namespace / and action name product-input.

            在配置struts.xml 文件时,会出现    There is no Action mapped for namespace / and action name ....    意思是没有product-input的映射文件或者是命名空间       出现这样的错误的原因后:     做如下检查:           1: 把struts.xml中的namespace="/"改成namespace=""或者去除,使用默认的命名空间. 2:

HTTP Status 404 - There is no Action mapped for namespace [/] and action name [Action!Method]错误解决

按照书本上的Struts2的例子,运行会出现错误: HTTP Status 404 - There is no Action mapped for namespace [/] and action name [sayHelloAction!sayStruts2] ... 貌似在struts.xml中配置action的method不会出错,而直接在jsp中写“Action!Method.action”就会报错. 搜索许久没有发现解决办法,后来发现第二种写法叫做“DMI”,会产生安全隐患,在stru

struts2中错误There is no Action mapped for namespace [/] and action name [] associated with context path

1 There is no Action mapped for namespace [/] and action name [] associated with context path [/Struts2_0300_Action2]. - [unknown location] 2 at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:185) 3 at org.apache.struts2.i

HTTP Status 404 - There is no Action mapped for namespace [/] and action name [product-save] associated with context path [/20161101-struts2-2].

运行:index.jsp---->input.jsp----->details.jsp,但是在input.jsp到details.jsp的时候报错误. 异常如下: 严重: Could not find action or result/There is no Action mapped for namespace [/] and action name [] associated with context path []. - [unknown location]at com.opensymp

There is no Action mapped for namespace [/] and action name [xx] associated with context path...

好久没用Struts了,今天练了一个简单的应用,出现了一些意外的问题,由于这种原因一直报404 首先我的目录结构是这样子滴 web.xml中是这样配置的 <web-app> <display-name>Archetype Created Web Application</display-name> <filter> <filter-name>struts2</filter-name> <filter-class>org.a

Struts2-tomcat报错:There is no Action mapped for namespace / and action

HTTP Status 404 - There is no Action mapped for namespace / and action name first. type Status report message There is no Action mapped for namespace / and action name first. description The requested resource is not available. Apache Tomcat/6.0.37 解

Struts2中关于&quot;There is no Action mapped for namespace / and action name&quot;的总结

今天在调试一个基础的Struts2框架小程序.总是提示"There is no Action mapped for namespace / and action name"的错误.上网查询后发现这是一个初学者经常碰到的问题,导致错误的原因主要有两种.总结如下: 一.struts.xml文件错误.这种错误又分为以下几种:1,struts.xml文件名错误.一定要注意拼写问 题:2,struts.xml文件放置路径错误.一定要将此文件放置在src目录下.编译成功后,要确认是否编译到clas

There is no Action mapped for namespace [/pages/action/student] and action name [findStudent]

1.错误描述 2014-7-13 2:38:54 org.apache.jasper.compiler.TldLocationsCache tldScanJar 信息: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were foun

There is no Action mapped for namespace [/] and action name [Login] associated

使用struts2时出现了: There is no Action mapped for namespace [/] and action name [Login] associated 两个可能的错误: 1.struts.xml大小等写错,或者不是放在src目录下. 解决方法:项目右键 ->properties ->Java Build Path ->source ->,要放在webRoot/WEB-INF目录下 2.可能是使用了通配符来配置. struts2.5后,使用通配符的