action继承ActionSupport后就不能交给spring管理了吗?
解决方案 »
- java linux操作word,替换某些文字
- Spring+jpa 怎么配置2个数据库
- 一个关于nutch里面url parse的问题,请教一下大家
- java 解析XML,谁能给我解释一下都什么意思呢?
- URL提交的一个奇怪问题,请高手指点,急!!!
- creating bean with name 'sessionFactory'这是什么错误啊?
- 高手近来看看,ajax问题。
- struts中上传文件的时候出现以下问题!大家帮忙解决下!
- tomcat+jsp 编wml问题,请高手帮忙
- 想知道java对”管道流“的操作,是怎么样实现的!
- java新手诚心请教各位高手(谢谢)
- 如何改写一个CSV文件
@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诸如错误了?