无法实例化的行动,cn.star.ssh.action.productaction
Unable to instantiate Action, cn.star.ssh.action.ProductAction, defined for 'product_save' in namespace '/'null
Unable to instantiate Action, cn.star.ssh.action.ProductAction, defined for 'product_save' in namespace '/'null
2016-10-11
package cn.star.ssh.action;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import cn.star.ssh.entity.Product;
import cn.star.ssh.service.ProductService;
/**
* 商品管理的Action的类
*/
public class ProductAction extends ActionSupport implements ModelDriven<Product>{
/**
*
*/
private static final long serialVersionUID = 1L;
// 模型驱动使用的类
private Product product = new Product();
@Override
public Product getModel() {
return product;
}
// Struts和Spring整合过程中按名称自动注入业务层的类
private ProductService productService;
public void setProductService(ProductService productService) {
this.productService = productService;
}
/**
* 保存商品的执行的方法:save
*/
public String save(){
System.out.println("Action中的save方法执行了...");
productService.save(product);
return NONE;
}
}
<?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"
xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.2.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.2.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa-1.3.xsd">
<!-- 配置业务层的类 -->
<bean id="productService" class="cn.star.ssh.service.ProductService">
<property name="productDao" ref="productDao"></property>
</bean>
<!-- 配置DAO的类 -->
<bean id="productDao" class="cn.star.ssh.dao.ProductDao">
</bean>
</beans>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<!-- Struts2配置 -->
<struts>
<package name="ssh" extends="struts-default" namespace="/">
<action name="product_save" class="cn.star.ssh.action.ProductAction" method="save">
</action>
</package>
</struts>
举报