这是我的applicationContext.xml的配置:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName">
<value>com.microsoft.sqlserver.jdbc.SQLServerDriver </value>
</property>
<property name="url">
<value>jdbc:sqlserver://localhost:1433;DatabaseName=db_personManager </value>
</property>
<property name="username">
<value>1 </value>
</property>
</bean>
<bean id="localSessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource"/>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.SQLServerDialect
</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>com/wy/form/ManagerForm.hbm.xml </value>
</list>
</property>
</bean>
<bean id="objectDao" class="com.wy.dao.ObjectDao">
<property name="sessionFactory">
<ref bean="localSessionFactory"/>
</property>
</bean>
<bean name="/manager" class="com.wy.action.ManagerAction" singleton="false">
<property name="objectDao">
<ref bean="objectDao"/>
</property>
</bean>
</beans>
下面是struts-config.xml的配置:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd">
<struts-config>
<form-beans>
<form-bean name="managerForm" type="com.wy.form.ManagerForm"/>
</form-beans>
<action-mappings>
<action path="/manager"
type="org.springframework.web.struts.DelegatingActionProxy"
name="managerForm"
validate="false"
scope="request"
parameter="method"
>
<forward name="managerCheck" path="/dealwith.jsp"/>
<forward name="queryManager" path="/manager_query.jsp"/>
<forward name="errorManager" path="/manager_insert.jsp"/>
</action>
</action-mappings>
<!--
SelfRequestProcessor继承了DelegatingRequestProcessor
-->
<controller processorClass="com.wy.tool.SelfRequestProcessor" />
<plug-in
className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation"
value="/WEB-INF/applicationContext.xml"/>
</plug-in>
</struts-config>
我的ManagerAction.java在com.wy.action这个包下。
启动服务器时总是抛出下面的异常:
严重: StandardWrapper.Throwable
org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [com.wy.action.ManagerAction] for bean with name '/manager' defined in ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is java.lang.ClassNotFoundException: com.wy.action.ManagerAction
Caused by: java.lang.ClassNotFoundException: com.wy.action.ManagerAction
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1358)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204)