那这是什么错啊: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'productTypeAction' defined in file [F:\eclipseWorkStation\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\baba\WEB-INF\classes\com\xiangshilong\action\producttype\ProductTypeAction.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.xiangshilong.action.producttype.ProductTypeAction]: Constructor threw exception; nested exception is java.lang.NullPointerException
异常是说构造函数中抛出空指针异常。 具体还不清楚是怎么回事,不过这里 Error creating bean with name 'productTypeAction'的bean改成id="productTypeAction",然后最好把这个action类中的代码贴出来下..
public class ProductTypeAction extends ActionSupport{
@Component
这样action就是spring bean
话说,struts2里面的action本身就是spring bean,只不过你表面上看不到而已,是由struts2的object factory屏蔽了这一层
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'productTypeAction' defined in file [F:\eclipseWorkStation\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\baba\WEB-INF\classes\com\xiangshilong\action\producttype\ProductTypeAction.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.xiangshilong.action.producttype.ProductTypeAction]: Constructor threw exception; nested exception is java.lang.NullPointerException
具体还不清楚是怎么回事,不过这里
Error creating bean with name 'productTypeAction'的bean改成id="productTypeAction",然后最好把这个action类中的代码贴出来下..
private ProductTypeServiceDao productTypeServiceDao;
public ProductTypeServiceDao getProductTypeServiceDao() {
return productTypeServiceDao;
} public void setProductTypeServiceDao(ProductTypeServiceDao productTypeServiceDao) {
this.productTypeServiceDao = productTypeServiceDao;
} private static final long serialVersionUID = 1L;
@Override
public String execute() throws Exception {
ProductType productType = productTypeServiceDao.find(ProductType.class, 1);
System.out.println(productType.getName());
HttpServletRequest request = ServletActionContext.getRequest();
request.setAttribute("productType", productType);
return SUCCESS;
}
private HttpServletRequest request = ServletActionContext.getRequest();时
就报spring诸如错误了?