其中的问题有:不能访问对应的action了,错误500,信息:defined for 'test' in namespace '/'Error creating bean with name 'testAction' defined in ServletContext resource [/WEB-INF/classes/applicationContext.xml]
还有一个基础问题,那个项目不是src下有个applicationContext.xml和Struts.xml吗,为什么WEB-INF/classes/里面还有相同的文件,而且web.xml里面又这样配
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/classes/applicationContext.xml</param-value>
</context-param>
那不是说,src下的两个配置文件都没用了吗?
还有,WEB-INF/classes/下面有整个项目的class文件,那是怎么生成到里面的,删除了会不会有影响。小弟刚接触SSH,低级问题还望见谅。
还有一个基础问题,那个项目不是src下有个applicationContext.xml和Struts.xml吗,为什么WEB-INF/classes/里面还有相同的文件,而且web.xml里面又这样配
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/classes/applicationContext.xml</param-value>
</context-param>
那不是说,src下的两个配置文件都没用了吗?
还有,WEB-INF/classes/下面有整个项目的class文件,那是怎么生成到里面的,删除了会不会有影响。小弟刚接触SSH,低级问题还望见谅。
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">
<bean id="testAction" class="com.zxt.action.TestAction" scope="prototype" >
<property name="testServer" ref="testServer" />
</bean>
<bean id="testServer" class="com.zxt.server.impl.TestServerImpl" scope="prototype">
<property name="testDao" ref="testDao" />
</bean>
<bean id="testDao" class="com.zxt.dao.impl.TestDaoImpl" scope="prototype" />
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<!-- 指定连接数据库的驱动 -->
<property name="driverClass" value="com.mysql.jdbc.Driver" />
<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/test">
</property>
<!-- 指定连接数据库的用户名 -->
<property name="user" value="root" />
<!-- 指定连接数据库的密码 -->
<property name="password" value="root" />
<!-- 指定连接数据库连接池的最大连接数 -->
<property name="maxPoolSize" value="40" />
<!-- 指定连接数据库连接池的最小连接数 -->
<property name="minPoolSize" value="1" />
<!-- 指定连接数据库连接池的初始化连接数 -->
<property name="initialPoolSize" value="1" />
<!-- 指定连接数据库连接池的连接的最大空闲时间 -->
<property name="maxIdleTime" value="20" />
</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>
<prop key="hibernate.format_sql">true</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>com/zxt/model/Test.hbm.xml</value>
</list>
</property>
</bean>
<!-- 声明一个 Hibernate 3 的 事务管理器供代理类自动管理事务用-->
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<aop:config>
<!-- 切入点指明了在执行com.ssh2.manager包中的所有方法时产生事务拦截操作 -->
<aop:pointcut id="daoMethods"
expression="execution(* com.zxt.*.*(..))" />
<!-- 定义了将采用何种拦截操作,这里引用到 txAdvice -->
<aop:advisor advice-ref="txAdvice" pointcut-ref="daoMethods" />
</aop:config>
<!-- 使用annotation定义事务,可以使用事务注解 -->
<tx:annotation-driven transaction-manager="transactionManager" />
<!-- 事务通知操作,使用的事务管理器引用自transactionManager -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<!-- 指定哪些方法需要加入事务 -->
<tx:method name="save*" propagation="REQUIRED" />
<tx:method name="delete*" propagation="REQUIRED" />
<tx:method name="update*" propagation="REQUIRED" />
<tx:method name="getWapTitleContextPage" propagation="REQUIRED" />
<!-- read-only="true":其余方法只读格式,加强其安全性 -->
<tx:method name="*" read-only="true" propagation="NOT_SUPPORTED" />
</tx:attributes>
</tx:advice>
<!-- 使Spring关注Annotation -->
<context:annotation-config />
<!-- 让Spring通过自动扫描来查询和管理Bean -->
<context:component-scan base-package="com.zxt" />
</beans>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/classes/applicationContext.xml</param-value>
</context-param>
那不是说,src下的两个配置文件都没用了吗?
还有,WEB-INF/classes/下面有整个项目的class文件,那是怎么生成到里面的,删除了会不会有影响。
但一拿到服务器来就出问题,估计也是spring配置struts的地方出了问题
但由于没接触过spring所以一直未能找到原因