ネームスペース/とアクション名 “yourActionName”に対してマッピングされたアクションはありません
問題
多くのStruts 2開発者は、アクションクラスを適切に設定していたが、アクションクラスにアクセスしている間にアクションエラーメッセージをヒットしたと主張しています。
エラーメッセージは次の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