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

struts 404 -- Servlet action is not available错误。。。。
web.xml与struts-config.xml文件都确认了,应该没有问题。。。文件名大小写也确认了。。。完全不了是怎么回事。。
麻烦大家帮忙看看,刚学struts,别笑哈~~~~

web.xml
----------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" 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">
<!-- Standard Action Servlet Configuration -->
<servlet>
<servlet-name>action</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>

<!-- Standard Action Servlet Mapping -->
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>

<!-- TheUsual Welcome File List -->
<welcome-file-list>
<welcome-file>hello.jsp</welcome-file>
</welcome-file-list>
</web-app>


struts-config.xml
-------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<struts-config>
<form-beans>
<form-bean name="sgus12001_DispatchForm" type="hello.b10s.manage.b10s.form.Sgus12001_DispatchForm"/>
</form-beans>
<action-mappings>
<action name="sgus12001_DispatchForm" 
scope="request" 
type="hello.b10s.manage.b10s.action.Sgus12001_DisplayAction" 
path="/SGUS12001_DisplayAction" 
validate="false">
<forward name="success" path="/SGUS12001.jsp"/>
<forward name="failure" path="/SGUS12001.jsp"/>
</action>
</action-mappings>
<message-resources parameter="ApplicationResources"/>
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property property="pathnames" value="/WEB-INF/validator-rules.xml, /WEB-INF/validation.xml"/>
</plug-in>
</struts-config>

jsp
--------------------------
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>

<html:html>
<head>
  <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
  <title>aaa</title>
  <link href="./css/style.css" rel="stylesheet">
</head>
<body>
  <div style="font-size: 10px" align="center">
  <html:form action="/SGUS12001_DisplayAction">
<html:submit value="submit"></html:submit>
  </html:form>
  </div>
</body>
</html:html>


------解决方案--------------------
把命名中的下划线去掉试试,我记得好像有一次也是的,死活都是404,最后发现是下划线的原因,LZ可以改得试一下!
------解决方案--------------------
<html:form action="/SGUS12001_DisplayAction