我在ECLIPSE里做测试,在做STRUTS+SPRING时可以正常运行,当加入HIBERNATE时产生,运行后,页面产生HTTP Status 404 - Servlet action is not available,我把applicationContext.xml里产生的HIBERNATE的部分删掉后,又可以正常的把STRUTS+SPRING部分运行出来,请看看这个文件是自动产生的,应该不会有问题吧<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> <bean name="/insert" class="com.ssh.struts.action.InsertAction"
abstract="false" lazy-init="default" autowire="default"
dependency-check="default">
</bean>
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName"
value="com.mysql.jdbc.Driver">
</property>
<property name="url">
<value>value="jdbc:mysql://127.0.0.1:3306/mysql"></value>
</property>
<property name="username"> <value>value="root"></value> </property>
<property name="password"> <value>value="123"></value> </property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>com/dao/Test.hbm.xml</value></list>
</property></bean>
<bean id="TestDAO" class="com.dao.TestDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="Test" class="com.dao.Test" abstract="false"
lazy-init="default" autowire="default" dependency-check="default">
</bean></beans>

解决方案 »

  1.   

    404错误是不可用的servlet,针对楼主的这个问题,可能是你配置的问题导致了系统启动失败,因为你这里关联了好几个配置文件,具体问题所在不好分析,只有楼主一步步的派查了,不过使用ssh编程的时候,不需要象楼主这样使用hibernate,直接使用spring来管理hibernte,使用jpa来进行数据操作会更好些,hibernate的配置还是很麻烦的
      

  2.   

    <bean id="dataSource" 
    class="org.apache.commons.dbcp.BasicDataSource"> 
    <property name="driverClassName" 
    value="com.mysql.jdbc.Driver"> 
    </property> 
    <property name="url"> 
    <value>value="jdbc:mysql://127.0.0.1:3306/mysql"> </value> 
    </property> 
    <property name="username">  <value>value="root"> </value>  </property> 
    <property name="password">  <value>value="123"> </value>  </property> 
    </bean> 
    <bean id="sessionFactory" 
    class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> 
    <property name="dataSource"> 
    <ref bean="dataSource" /> 
    </property> 
    <property name="hibernateProperties"> 
    <props> 
    <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect </prop> 
    <prop key="hibernate.show_sql">true </prop> 
    </props> 
    </property> 
    <property name="mappingResources"> 
    <list> 
    <value>com/dao/Test.hbm.xml </value> </list> 
    </property> </bean> 
    <bean id="TestDAO" class="com.dao.TestDAO"> 
    <property name="sessionFactory"> 
    <ref bean="sessionFactory" /> 
    </property> 
    </bean> 
    我就把这段删了,STRUTS+SPRING就可以正常运行,上面代码全都照视频做,自动产生的,感觉怎么都不会有错啊,都没手写的
      

  3.   

    用MYECLIPSE自动加入HIBERNATE的,包应该都自动加入进去了吧
      

  4.   

    <bean id="sessionFactory"  
    class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">  
    <property name="dataSource">  
    <ref bean="dataSource" />  
    </property>  
    <property name="hibernateProperties">  
    <props>  
    <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect  </prop>  
    <prop key="hibernate.show_sql">true  </prop>  
    </props>  
    </property>  
    <property name="mappingResources">  
    <list>  
    <value>com/dao/Test.hbm.xml  </value>  </list>  
    </property>  </bean>  
    应该主要是这段,这段删了就可以正常运行