今天測(cè)試別人的程序,發(fā)現(xiàn)struts的配置文件出了問(wèn)題,主要有兩個(gè)(以前沒(méi)用過(guò)struts1,網(wǎng)上很多人的解答也對(duì)不上),

一個(gè)是web.xml文件中的struts配置文件路徑的寫(xiě)法問(wèn)題,解決辦法是在struts配置文件路徑前加上"/"
<init-param>
   <param-name>config</param-name>
   <param-value>/struts_test.xml</param-value>
  </init-param>
拋的異常如下:
2009-9-28 13:33:53 org.apache.struts.action.ActionServlet handleConfigException
嚴(yán)重: Parsing error processing resource path struts_test.xml
java.net.MalformedURLException: Path struts_test.xml does not start with a "/" c
haracter
        at org.apache.catalina.core.ApplicationContext.getResource(ApplicationCo
ntext.java:473)


一個(gè)是web.xml中的struts文件的路徑,struts配置文件應(yīng)該是放在class目錄下,比如src的根目錄下,
配置就是<param-value>/struts_test.xml</param-value>,而不是WEB-INF中的路徑。

嚴(yán)重:   Servlet   /Message   threw   load()   exception
javax.servlet.UnavailableException:   Missing   configuration   resource   for   path   /WEB-INF/struts-config.xml
at   org.apache.struts.action.ActionServlet.parseModuleConfigFile(ActionServlet.java:732)
at   org.apache.struts.action.ActionServlet.initModuleConfig(ActionServlet.java:687)
at   org.apache.struts.action.ActionServlet.init(ActionServlet.java:333)