问题描述
- 关于spring整合struts的问题
-
我applicationContext中的配置和action里面的内容如下:<bean id="productService" class="com.store.serviceImpl.ProductServiceImpl"> <property name="pdao" ref="productDao"/> </bean
<bean name="allproductAction" class="com.store.action.AllProductAction" scope="prototype"> <property name="pservice" ref="productService"/> </bean>
public class AllProductAction extends ActionSupport{
private ProductService pservice;
private List product;
private int productID;
public ProductService getPservice() {
return pservice;
}
public void setPservice(ProductService pservice)
{
this.pservice = pservice;
}public List<Product> getCommodity() { return product; } public void setCommodity(List<Product> product) { this.product = product; } public int getproductID() { return productID; } public void setproductID(int productID) { this.productID = productID; } public String execute() throws Exception { product = pservice.findAll(); return SUCCESS; }
}
为什么我运行之后会提示一下错误:
严重: Could not open template
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'allproductAction' defined in ServletContext resource [/WEB-INF/applicationContext-actions.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'pservice' of bean class [com.store.action.AllProductAction]: Bean property 'pservice' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
求大神指教啊!
解决方案
pservice你看看这个属性你家的对吗。这个属性的对应set get 你加的对方