u013006498
小小程序猿gm
2016-04-09 15:38

Spring和Strut2整合项目中报404错误

  • spring
  • struts

这个配置文件最后一段注释了的部分,一打开注释就直接404错误。这几个类写得都没什么问题啊,为什么一配置bean就出错呢?
补充:我找了半天发现问题是这样的:开始的时候我用的Spring的注释来配置bean,之后运行了一下项目出错了,我就删除了注释而改在applicationContext.xml中配置bean,然后其他地方的错改正了,但就是这几个配置的bean有问题。我试过了删除再重新配置也不行,难道是注释自动装配的bean会一直存在在IOC容器中,但不是每次web应用初始化都会重新建立IOC容器的吗?我试着删除了 原来的类重新创建了一个新类(类名变一下,bean的id也变一下)就可以了。这是什么原因?
<?xml version="1.0" encoding="UTF-8"?>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">

<context:property-placeholder location="classpath:db.properties"/>
<bean id="dataSource"
    class="com.mchange.v2.c3p0.ComboPooledDataSource">
    <property name="user" value="${db.user}"></property>
    <property name="password" value="${db.password}"></property>
    <property name="driverClass" value="${db.driverClass}"></property>
    <property name="jdbcUrl" value="${db.jdbcUrl}"></property>
    <property name="initialPoolSize" value="${db.initialPoolSize}"></property>
    <property name="maxPoolSize" value="${db.maxPoolSize}"></property>
</bean>
<bean id="sessionFactory"
    class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="dataSource">
        <ref bean="dataSource" />
    </property>
    <property name="configLocation" value="classpath:hibernate.cfg.xml"></property>
    <property name="mappingLocations" value="classpath:com/gm/ssh/entities/*.hbm.xml"></property>
</bean>

<!-- 
<bean id="employeeDAO" class="com.gm.ssh.dao.EmployeeDAO">
    <property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<bean id="employeeService" class="com.gm.ssh.service.EmployeeService">
    <property name="employeeDAO" ref="employeeDAO"></property>
</bean>
<bean id="employeeAction" class="com.gm.ssh.action.EmployeeAction" scope="prototype">
    <property name="employeeService" ref="employeeService"></property>
</bean>
 -->

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

4条回答