这是页面的错误。
这是控制台的错误
二月 23, 2014 6:16:05 下午 org.apache.struts2.dispatcher.Dispatcher error
SEVERE: Exception occurred during processing request: Unable to instantiate Action, com.action.Move_bookAction, defined for 'book' in namespace '/'Error creating bean with name 'com.action.Move_bookAction': Injection of resource methods failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'bookDaoImpl' is defined
Unable to instantiate Action, com.action.Move_bookAction, defined for 'book' in namespace '/'Error creating bean with name 'com.action.Move_bookAction': Injection of resource methods failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'bookDaoImpl' is defined
at com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:316)
at com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:397)
at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:194)
at org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:63)
------------------这是Action:---------------------
package com.dao.impl;
import javax.annotation.Resource;
import org.hibernate.SessionFactory;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.springframework.stereotype.Repository;
import com.dao.Move_bookDao;
import com.entity.Move_booking;
@Repository(value="bookDaoImpl")
public class Move_bookDaoImpl extends HibernateDaoSupport implements Move_bookDao{
@Override
public void addMove_book(Move_booking book) {
// TODO Auto-generated method stub
this.getHibernateTemplate().save(book);
}
@Resource(name="sf")
public void setSf(SessionFactory sf){
super.setSessionFactory(sf);
}
}
----------这是MoveBookDaoimpl----------------
package com.dao.impl;
import javax.annotation.Resource;
import org.hibernate.SessionFactory;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.springframework.stereotype.Repository;
import com.dao.Move_bookDao;
import com.entity.Move_booking;
@Repository(value="bookDaoImpl")
public class Move_bookDaoImpl extends HibernateDaoSupport implements Move_bookDao{
@Override
public void addMove_book(Move_booking book) {
// TODO Auto-generated method stub
this.getHibernateTemplate().save(book);
}
@Resource(name="sf")
public void setSf(SessionFactory sf){
super.setSessionFactory(sf);
}
}
--------------------------这是applicationContext.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:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
">
<context:component-scan base-package="comm" />
<!-- 配置数据源 -->
<bean id="ds" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/>
<property name="url" value="jdbc:oracle:thin:@localhost:1521:orcl" />
<property name="username" value="David" />
<property name="password" value="qweqwe" />
</bean>
<!-- SessionFactory -->
<bean id="sf" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="ds"></property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.Oracle9iDialect
</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
</props>
</property>
<property name="packagesToScan" value="com.entity" />
</bean>
</beans>
<context:component-scan base-package="comm" /> 配置错误了