没有为名称空间/映射任何操作,并且操作名称为“ yourActionName”

问题

许多Struts 2开发人员声称他们已经正确配置了操作类,但是在访问操作类时却遇到了操作错误消息。

查看两种模式下的错误消息:

1.“ struts.devMode”已关闭(默认)

HTTP Status 404 - 
There is no Action mapped for namespace / and action name "yourActionName".

type Status report 

message There is no Action mapped for namespace / and action name "yourActionName".

description The requested resource 
(There is no Action mapped for namespace / and action name "yourActionName".) is not available.

2.打开struts.devMode

struts.xml

<constant name="struts.devMode" value="true" />
Struts Problem Report

Struts has detected an unhandled exception:

Messages:	
There is no Action mapped for namespace / and action name "yourActionName".
Stacktraces

There is no Action mapped for namespace / and action name "yourActionName". - [unknown location]
    com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:178)
    org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:61)
   ...
    
You are seeing this page because development mode is enabled. Development mode, or devMode, 
enables extra debugging behaviors and reports to assist developers. To disable this mode, set:

  struts.devMode=false
in your WEB-INF/classes/struts.properties file.

上面的错误消息表示操作类不可用,这意味着您在操作类配置中做错了什么,可能是名称空间拼写错误,请仔细检查名称。

这是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>
 	<constant name="struts.devMode" value="true" />
	<package name="default" namespace="/" extends="struts-default">
	
		<action name="abcAction" 
			class="com.mkyong.common.action.AbcAction" >
			<result name="success">pages/abc.jsp</result>
		</action>
		
	</package>
</struts>

假设项目的根上下文是“ Struts2Example ”,那么您可以通过此URL访问上述操作–
http:// localhost:8080 / Struts2Example / abcAction.action

翻译自: https://mkyong.com/struts2/there-is-no-action-mapped-for-namespace-and-action-name-youractionname/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值