1. 程式人生 > >Struts2報There is no Action mapped for action name calaction_mul.的錯

Struts2報There is no Action mapped for action name calaction_mul.的錯

一、struts.xml檔案錯誤。這種錯誤又分為以下幾種:

1,struts.xml檔名錯誤。

2,struts.xml檔案放置路徑錯誤。一定要將此檔案放置在src目錄下。

3,struts.xml檔案內容錯誤。下面給出一個正確的struts.xml檔案以供參考。

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.5//EN"
    "http://struts.apache.org/dtds/struts-2.5.dtd">
<struts>
    <package name="hw" extends="struts-default"  namespace="/hw">
        <!--匹配正則-->
        <global-allowed-methods>regex:.*</global-allowed-methods>
        <action name="calaction_*"  class="com.hw.one.web.CalAction" method="{1}">
            <result name="CalResult">/demo1/CalResult.jsp</result>
        </action>
    </package>
</struts>

二、如果排除了struts.xml檔案的問題,還有一種可能就是,在web.xml檔案中的<filter>資訊中是否配置了自己工程的啟動頁面。

    <filter>
        <filter-name>struts2</filter-name>
        <filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter
        </filter-class>
    </filter>
    <filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>