首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

自定义标签怎么进行spring的@Autowired

2013-11-29 
自定义标签如何进行spring的@Autowired自定义了一个tag,里面需要引用到service层,利用@Autowired注解,永远

自定义标签如何进行spring的@Autowired
自定义了一个tag,里面需要引用到service层,利用@Autowired注解,永远得不到service对象,这是为什么呢

public class CataTag extends BodyTagSupport {
/**
 * 
 */
private static final long serialVersionUID = 1L;

@Autowired
public HSListViewComponent sysCataViewComponent;

[解决办法]
spring 配置文件 applicationContext.xml 里加入
<bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor"/>  
了没,Spring 通过一个 BeanPostProcessor 对 @Autowired 进行解析,所以要让 @Autowired 起作用必须事先在 Spring 容器中声明 AutowiredAnnotationBeanPostProcessor Bean。
[解决办法]
因为它没被Spring托管  所以写注解白写

热点排行