現象:JSP 正常訪問,Action 返回 404,Tomcat 無錯誤,Action 斷點不進入。
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping> 確保攔截所有請求。<package name="..." namespace="/user">,則訪問路徑需為 /user/xxx.action。*.action,若改為 *.do 需在 struts.properties 配置 struts.action.extension=do。<action name="login" class="com.xxx.action.LoginAction"> 類名拼寫、包路徑無誤。https://localhost:8080/項目名/struts-config-browser/index.jsp(需加 struts2-config-browser-plugin 依賴),查看所有 Action 映射。log4j.logger.org.apache.struts2=DEBUG 觀察 Action 解析過程。