动作名称elecMenuAction_menuHome没有映射动作

时间:2017-04-04 09:34:33

标签: java jsp struts struts-config

  

Struts问题报告

     

Struts检测到未处理的异常:

     

消息:
  动作名称elecMenuAction_menuHome没有映射动作。

     

踪迹

     

动作名称elecMenuAction_menuHome没有映射动作。 - [未知位置]

     

com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:185)   org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:63)   org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)   com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58)   org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:500)   org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)   org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)   org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)   org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)   org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:218)   org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:110)   org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:506)

     

...

我的struts.xml

<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
    "http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
    <!-- dev model -->
    <constant name="struts.devMode" value="true"></constant>
    <!-- ui  -->
    <constant name="struts.ui.theme" value="simple"></constant>
    <!-- .do-->
    <constant name="struts.action.extension" value="do"></constant>

    <!-- system management -->
    <package name="system" namespace="/system" extends="struts-default">
        <!-- test -->
        <action name="elecTextAction_*" class="elecTextAction" method="{1}">
            <result name="save">/system/textAdd.jsp</result>
        </action>

        <action name="elecMenuAction_*" class="elecMenuAction" method="{1}">
            <result name="menuHome">/WEB-INF/page/menu/home.jsp</result>
        </action>  // I add this action then report error.
    </package>
</struts>

在我的ElecMenuAction.java

@SuppressWarnings("serial")
@Controller("elecMenuAction")
@Scope(value = "prototype")
public class ElecMenuAction extends BaseAction<MenuForm> {

    MenuForm menuForm = this.getModel();

    public String menuHome(MenuForm menuForm) {

        return "menuHome";
    }

}

在我的menu/index.jsp

<form action="${pageContext.request.contextPath}/menu/elecMenuAction_menuHome.do" method="post" target="_top">

我的目录如下:

1 个答案:

答案 0 :(得分:0)

我在struts.xml看到你的包配置是这样的:

<package name="system" namespace="/system" extends="struts-default">

但您的表单操作如下所示,为什么menu只有system

<form action="${pageContext.request.contextPath}/menu/elecMenuAction_menuHome.do" method="post" target="_top">

您应该将action更改为:

action="${pageContext.request.contextPath}/system/elecMenuAction_menuHome.do"

这就是为什么Action映射找不到原因。