我用的Struts1.3+Hibernate3.1+spring2.0框架做的简单的整合执行测试,在IE浏览器出现如下错误:
HTTP Status 404 - Servlet action is not available
--------------------------------------------------------------------------------
type Status reportmessage Servlet action is not availabledescription The requested resource (Servlet action is not available) is not available.--------------------------------------------------------------------------------
Apache Tomcat/6.0.13在myeclipse8.0中的控制台有如下错误提示:
2010-5-16 14:52:47 org.apache.catalina.core.StandardWrapperValve invoke
信息: Servlet action is currently unavailable请问这种错误一般是什么原因呢?表单提交代码:
<html:form action="/create_table1.do">
username : <html:text property="username"/><html:errors property="username"/><br/>
age : <html:text property="age"/><html:errors property="age"/><br/>
password : <html:password property="password"/><html:errors property="password"/><br/>
<html:submit/><html:cancel/>
</html:form>create_table1Action的代码:
@Transactional(propagation=Propagation.REQUIRED)
public class Create_table1Action extends BaseAction {

public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
Create_table1Form create_table1Form = (Create_table1Form) form;

Table1 Table1=new Table1();
Table1.setUsername(create_table1Form.getUsername());
Table1.setAge(create_table1Form.getAge().toString());
Table1.setPassword(create_table1Form.getPassword());

Table1DAO table1Dao=new Table1DAO();
Transaction tra=table1Dao.getSessionFactory().openSession().beginTransaction();

table1Dao.attachDirty(Table1);

tra.commit();
table1Dao.getSessionFactory().close();
return null;
}
}

解决方案 »

  1.   

    在struts-config.xml中的代码<struts-config>
      <form-beans >
        <form-bean name="create_table1Form" type="com.yourcompany.struts.form.Create_table1Form" />  </form-beans>
    <global-exceptions />
      <global-forwards />
      <action-mappings >
        <action
          path="/base"
          type="com.yourcompany.struts.action.BaseAction"
          cancellable="true" />
        <action
          attribute="create_table1Form"
          input="/form/create_table1.jsp"
          name="create_table1Form"
          path="/create_table1"
          scope="request"
          type="com.yourcompany.struts.action.Create_table1Action"
          cancellable="true" />  </action-mappings>  <controller
          processorClass="org.springframework.web.struts.DelegatingRequestProcessor">
      </controller>
      <plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
      <set-property property="contextConfigLocation" value="/WEB-INF/classes/applicationContext.xml"/>
      </plug-in>
      <message-resources parameter="com.yourcompany.struts.ApplicationResources" />
    </struts-config>
      

  2.   

    在applicationComtext.xml中的代码<?xml version="1.0" encoding="UTF-8"?>
    <beans
    xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:p="http://www.springframework.org/schema/p"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd 
             http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd 
             http://www.springframework.org/schema/aop http://www.springframework.org/schema/tx/spring-aop.xsd">
    <bean id="sessionFactory"
    class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="configLocation"
    value="classpath:hibernate.cfg.xml">
    </property>
    </bean>
    <tx:annotation-driven transaction-manager="transactionManager" />
    <bean id="Table1DAO" class="orm.Table1DAO">
    <property name="sessionFactory">
    <ref bean="sessionFactory" />
    </property>
    </bean>
    <bean id="all_dao" class="orm.All_DAO">
    <property name="table1dao" ref="Table1DAO"></property>
    </bean>
    <bean id="table1_service" class="service.Table1_Service">
    <property name="all_dao" ref="all_dao"></property></bean>
    <bean id="all_service" class="service.All_Service">
    <property name="table1_service" ref="table1_service"></property>
    </bean>
    <bean id="base" class="com.yourcompany.struts.action.BaseAction">
    <property name="all_service" ref="all_service"></property>
    </bean>
    <bean name="/create_table1" class="com.yourcompany.struts.action.Create_table1Action" parent="base">
    </bean>
    <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory"></property>
    </bean></beans>
      

  3.   

    多了一个jar包
    让你的配置文件没能够加载成功
    要么就是配置错了
      

  4.   

    这种错误的原因是因为form表单里没有 method="post" action=""参数,加上就好了啊
      

  5.   

    这是Struts的标签,我以前的也不用的,好像和这个没关系的