程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程綜合問答 >> struts2-關於spring整合struts的問題

struts2-關於spring整合struts的問題

編輯:編程綜合問答
關於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 你加的對方

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved