我自定义了一个Filter需要数据库操作
代码片段如下:
@IocBean
public class UserFilter implements ActionFilter {
@Inject private UserService userService;
.....
}
Module 入口调用如下:
@Filters(@By(type=UserFilter.class))
此时启动无报错,调用Module 入口时,报错userService为null
此后修改为下
public class UserFilter implements ActionFilter {
private UserService userService;
public UserFilter(UserService userService) {
this.userService = userService;
}
.....
}
对应Service如下:
@IocBean
public class UserService {
@Inject private DBAgent dba;
.......
}
Module 入口调用如下:
@Filters(@By(type=UserFilter.class, args={"/jsp/login.jsp","ioc:userService"}))
dao.js配置中无userService此bean
此时启动报错如下:
org.nutz.mvc.LoadingException: org.nutz.castor.FailToCastObjectException: Fail to cast from <java.lang.String> to <com.limit.service.UserService> for {ioc:userService} because:
BorningException:Fail to born 'com.limit.service.UserService'
by args: [
@(ioc:userService)]
.......
** 问题**
请问下我是否需要在dao.js中配置bean [userService]
我在类UserService头已经加入注解@IocBean和@Inject private DBAgent dba;
此时再配置bean [userService] 是否会重复或者有问题
正确的配置方法应该如何操作 包含@Filters(@By(type=UserFilter.class))的配置 麻烦大神指导一下