一、struts.xml文件錯誤。這種錯誤又分爲以下幾種:1,struts.xml文件名錯誤。一定要注意拼寫問題;2,struts.xml文件放置路徑錯誤。一定要將此文件放置在src目錄下。編譯成功後,要確認是否編譯到classes目錄中;3,struts.xml文件內容錯誤。下面給出一個正確的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> <package name="default" namespace="/" extends="struts-default"> <action name="login" class="com.wanggc.struts2.sample.Struts2Action"> <result name="success">/jsp/result.jsp</result> </action> </package> </struts>
二、如果排除了struts.xml文件的問題,還有一種可能就是,在web.xml文件中的<welcome-file>信息中是否配置了自己工程的啓動頁面。如果沒有配置,地址欄中要輸入完成的url,如:http://localhost:8080/Struts2Sample/jsp/login.jsp,後面的資源詳細信息不輸入的時候也會報這個錯誤,我就是栽在這個問題上的(^_^)。
原網站:http://www.cnblogs.com/gulvzhe/archive/2011/11/21/2256632.html