我最近在看SPRING自动装配
在属性名前加@Resource
@Resource
private IJDBCManagers testManagerx; public String execute() throws Exception {
// testManagerx = (IJDBCManagers) ContextManage.
getApplicationContext().getBean("testManagerx"); functionPage = testManagerx.findAllTest();
ActionContext ctx = ActionContext.getContext();
    HttpServletRequest request = (HttpServletRequest)ctx.get(ServletActionContext.HTTP_REQUEST);
        request.setAttribute("list",functionPage);
return "success";
} public void setTestManagerx(IJDBCManagers testManagerx) {
this.testManagerx = testManagerx;
}ContextManage不要去管他,是封装的方法是没任何问题的,我这里加了@Resource,但是当
testManagerx = (IJDBCManagers) ContextManage.
getApplicationContext().getBean("testManagerx");这里注释掉以后就获取不到了,报空指针异常了,大家给我说说自动装配是怎么回事哦,我觉得这里应该不要写testManagerx = (IJDBCManagers) ContextManage.
getApplicationContext().getBean("testManagerx");了啊,不是根据配置文件里面的ID拿到了吗??