首页 新闻 会员 周边

springMvc 注解service,但是不能实例化子类

0
悬赏园豆:5 [待解决问题]

@Controller
@RequestMapping("/role")
@Scope("prototype")
public class RoleController {
@Resource(name="roleService")
public DbService<Role> roleService;
/**
* 未能扩展成功
* @return
*/
@RequestMapping("/test")
public String test(){
if(roleService instanceof RoleServiceImpl){
((RoleServiceImpl) roleService).test();
System.out.println("-----------不会执行此方法-----------");
}
return "/user/role/roleList";
}

 

RoleServiceImpl 实现了DbService接口

public class RoleServiceImpl extends DbServiceImpl<Role> implements DbService<Role>{
//RoleDaoImpl roleDaoImpl=(RoleDaoImpl) this.getDao();
public void test(){
System.out.println("测试一下serviceImpl特有的方法");
//roleDaoImpl.test();
}
}

 

疑问点:

1.RoleServiceImpl实现了DbService接口,在controller中,我想调用实现类中特有的方法,但是通过接口得不到实现类。instanceof都没有成功,请各位大拿指点迷津

numberbb的主页 numberbb | 菜鸟二级 | 园豆:211
提问于:2015-06-21 15:45
< >
分享
所有回答(2)
0

给 roleService一个get、set方法,@Resource(name="roleService")放在set方法上面,spring mvc不是很熟,不过之前用ssh,@Resource都是放在set方法上面的。楼主你试试。

xzq_no3 | 园豆:226 (菜鸟二级) | 2015-06-22 08:43
0

aaaaaaaaa

numberbb | 园豆:211 (菜鸟二级) | 2017-03-15 09:35
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册