日期:2014-05-18  浏览次数:20693 次

刚开始学struts,到处搜不到答案
错误:
type   Status   report

message   Servlet   acitonServlet   is   not   available

description   The   requested   resource   (Servlet   acitonServlet   is   not   available)   is   not   available.

struts-config.xml
<?xml   version= "1.0 "   encoding= "UTF-8 "?>

<struts-config>
<form-beans>
<form-bean   name= "formBean1 "   type= "classmate.UserForm "   />
</form-beans>

<global-forwards>
<forward   name= "failed "   path= "/error.jsp "   />
<forward   name= "successed "   path= "/right.jsp "   />
</global-forwards>

<action-mappings>
<action   path= "/login "   type= "classmate.LoginAction "   name= "formBean1 "  
scope= "request "   input= "/login.jsp "   />
<action   path= "/regist "   forward= "/regist.jsp "   />
</action-mappings>
</struts-config>

web.xml
<?xml   version= "1.0 "   encoding= "UTF-8 "?>
<web-app   version= "2.4 "  
xmlns= "http://java.sun.com/xml/ns/j2ee "  
xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance "  
xsi:schemaLocation= "http://java.sun.com/xml/ns/j2ee  
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd ">

<!--   Action   Serlvet的配置-->
<servlet>
<servlet-name> acitonServlet </servlet-name>
<servlet-class> org.apache.struts.action.ActionServlet </servlet-class>
</servlet>

<!--   Action   Serlvet   Mapping的配置-->
<servlet-mapping>
<servlet-name> acitonServlet </servlet-name>
<url-pattern> *.do </url-pattern>
</servlet-mapping>

<!--   The   Welcome   File   List-->
<welcome-file-list>
<welcome-file> login.jsp </welcome-file>
</welcome-file-list>
</web-app>


------解决方案--------------------
acitonServlet这个servlet映射的时候出现了错误,

可能是没找到org.apache.struts.action.ActionServlet这个类,比如你没添加struts的jar文件到你项目构建路径(就是WEB-INF/lib目录下)。要么就是你的版本不对,struts2中已经不存在这个类了,你的这个配置是针对struts1的。

另外你的配置还有问题
<servlet>
<servlet-name> acitonServlet </servlet-name>
<servlet-class> org.apache.struts.action.ActionServlet </servlet-class>
</servlet>

改为
<servlet>
<servlet-name> acitonServlet </servlet-name>
<servlet-class> org.apache.struts.action.ActionServlet </servlet-class>
<init-param>
<param-name> config </param-name>
<param-value> /WEB-INF/struts-config.xml </param-value>
</init-param>
<load-on-startup> 2 </load-on-startup>
</servlet>


好好看看struts自带的例子吧