NutzCN Logo
问答 通过Aop,实现对com.kanq.action里面的所有类方法,进入日志记录
发布于 3258天前 作者 qq_5208486d 1813 次浏览 复制 上一个帖子 下一个帖子
标签:

js文件如下:

var ioc = {
log: {
type: 'org.nutz.aop.interceptor.LoggingMethodInterceptor'
}, $aop: {
type: 'org.nutz.ioc.aop.config.impl.JsonAopConfigration',
fields: {
itemList: [
['com.kanq.action..+', '.+', 'ioc:log']
]
}
}
}

itemList,换成 .+,切入全部的类方法,也没行通,大家帮忙看下

12 回复

看日志,里面会提示加载了什么,是否应用来了aop

只有从ioc取出的对象才可能被aop

@wendal 页面 进入了loginAction ,大致内容如下

@IocBean
public class LoginAction {

@At("login")
public void login(int userId,String userName){
}

}
这样的情况,是从IOC 取的对象吗?

@wendal

内容如下

@IocBean
public class LoginAction {

@At("login")
public void login(int userId,String userName){
}

}

@qq_5208486d 恩,看看后台的日志,会有aop字样

@wendal
没有发现呀

@wendal
只是有这句

Loaded 2 bean define from path=[com/kanq/demo3/nutz-content.js] --> [$aop, log]

@qq_5208486d 贴出来看看,第一次取ioc对象的时候肯定有日志

16-1-21 20:37:0.439 DEBUG [RMI TCP Connection(3)-127.0.0.1] MainModule: <com.kanq.demo3.MainModule>
16-1-21 20:37:0.454 DEBUG [RMI TCP Connection(3)-127.0.0.1] Loading by class org.nutz.mvc.impl.NutLoading
16-1-21 20:37:0.460 INFO [RMI TCP Connection(3)-127.0.0.1] Nutz Version : 1.r.54.r2
16-1-21 20:37:0.460 INFO [RMI TCP Connection(3)-127.0.0.1] Nutz.Mvc[nutz] is initializing ...
16-1-21 20:37:0.460 DEBUG [RMI TCP Connection(3)-127.0.0.1] Web Container Information:
16-1-21 20:37:0.462 DEBUG [RMI TCP Connection(3)-127.0.0.1] - Default Charset : GBK
16-1-21 20:37:0.462 DEBUG [RMI TCP Connection(3)-127.0.0.1] - Current . path : C:\work\workspace\server\tomcat7_idea\bin.
16-1-21 20:37:0.463 DEBUG [RMI TCP Connection(3)-127.0.0.1] - Java Version : 1.6.0_20
16-1-21 20:37:0.463 DEBUG [RMI TCP Connection(3)-127.0.0.1] - File separator : \
16-1-21 20:37:0.463 DEBUG [RMI TCP Connection(3)-127.0.0.1] - Timezone : Asia/Shanghai
16-1-21 20:37:0.463 DEBUG [RMI TCP Connection(3)-127.0.0.1] - OS : Windows NT (unknown) x86
16-1-21 20:37:0.463 DEBUG [RMI TCP Connection(3)-127.0.0.1] - ServerInfo : Apache Tomcat/7.0.42
16-1-21 20:37:0.464 DEBUG [RMI TCP Connection(3)-127.0.0.1] - Servlet API : 3.0
16-1-21 20:37:0.464 DEBUG [RMI TCP Connection(3)-127.0.0.1] - ContextPath :
16-1-21 20:37:0.465 DEBUG [RMI TCP Connection(3)-127.0.0.1] MainModule: <com.kanq.demo3.MainModule>
16-1-21 20:37:0.466 DEBUG [RMI TCP Connection(3)-127.0.0.1] >> app.root = C:/work/workspace/idea15/glass/out/artifacts/NutzDemo2_war_exploded
16-1-21 20:37:0.571 DEBUG [RMI TCP Connection(3)-127.0.0.1] Using 94 castor for Castors
16-1-21 20:37:0.578 DEBUG [RMI TCP Connection(3)-127.0.0.1] @IocBy(type=org.nutz.mvc.ioc.provider.ComboIocProvider, args=["*json", "com/kanq/demo3/nutz-content.js"],init=[])
16-1-21 20:37:0.605 DEBUG [RMI TCP Connection(3)-127.0.0.1] Found 1 resource by src( com/kanq/demo3/nutz-content.js ) , regex( ^(.+[.])(js|json)$ )
16-1-21 20:37:0.605 DEBUG [RMI TCP Connection(3)-127.0.0.1] loading ioc js config from [nutz-content.js]
16-1-21 20:37:0.610 DEBUG [RMI TCP Connection(3)-127.0.0.1] Loaded 2 bean define from path=[com/kanq/demo3/nutz-content.js] --> [$aop, log]
16-1-21 20:37:0.614 INFO [RMI TCP Connection(3)-127.0.0.1] NutIoc init begin ...
16-1-21 20:37:0.618 INFO [RMI TCP Connection(3)-127.0.0.1] ... NutIoc init complete
16-1-21 20:37:0.619 DEBUG [RMI TCP Connection(3)-127.0.0.1] MainModule: <com.kanq.demo3.MainModule>
16-1-21 20:37:0.623 INFO [RMI TCP Connection(3)-127.0.0.1] Build URL mapping by org.nutz.mvc.impl.UrlMappingImpl ...
16-1-21 20:37:0.627 DEBUG [RMI TCP Connection(3)-127.0.0.1] @Views(DefaultViewMaker)
16-1-21 20:37:0.635 DEBUG [RMI TCP Connection(3)-127.0.0.1] @ChainBy(org.nutz.mvc.impl.NutActionChainMaker)
16-1-21 20:37:0.649 DEBUG [RMI TCP Connection(3)-127.0.0.1] module class location 'file:/C:/work/workspace/idea15/glass/out/artifacts/NutzDemo2_war_exploded/WEB-INF/classes/com/kanq/demo3/MainModule.class'
16-1-21 20:37:0.649 DEBUG [RMI TCP Connection(3)-127.0.0.1] > scan 'com.kanq.demo3'
16-1-21 20:37:0.653 DEBUG [RMI TCP Connection(3)-127.0.0.1] Found 4 resource by src( com/kanq/demo3/ ) , regex( ^.+[.]class$ )
16-1-21 20:37:0.665 DEBUG [RMI TCP Connection(3)-127.0.0.1] >> add 'com.kanq.demo3.LoginAction'
16-1-21 20:37:0.668 DEBUG [RMI TCP Connection(3)-127.0.0.1] >> add 'com.kanq.demo3.MainModule'
16-1-21 20:37:0.683 WARN [RMI TCP Connection(3)-127.0.0.1] Moudle with @InjectName('loginAction') or @IocBean('loginAction') but no such ioc bean found!! Pls check your ioc configure!!
16-1-21 20:37:0.689 INFO [RMI TCP Connection(3)-127.0.0.1] Optional processor class not found, disabled : org.nutz.integration.shiro.NutShiroProcessor
16-1-21 20:37:0.707 INFO [RMI TCP Connection(3)-127.0.0.1] Optional processor class not found, disabled : org.nutz.plugins.validation.ValidationProcessor
16-1-21 20:37:0.722 WARN [RMI TCP Connection(3)-127.0.0.1] Moudle with @InjectName('loginAction') or @IocBean('loginAction') but no such ioc bean found!! Pls check your ioc configure!!
16-1-21 20:37:0.722 DEBUG [RMI TCP Connection(3)-127.0.0.1] '/login' >> LoginAction.login(...) : void | @Ok(null ) @Fail(->:/fail) | by 0 Filters | (I:UTF-8/O:UTF-8)
16-1-21 20:37:0.734 WARN [RMI TCP Connection(3)-127.0.0.1] Moudle with @InjectName('loginAction') or @IocBean('loginAction') but no such ioc bean found!! Pls check your ioc configure!!
16-1-21 20:37:0.734 DEBUG [RMI TCP Connection(3)-127.0.0.1] '/login2' >> LoginAction.login2(...) : void | @Ok(null ) @Fail(->:/fail) | by 0 Filters | (I:UTF-8/O:UTF-8)
16-1-21 20:37:0.735 DEBUG [RMI TCP Connection(3)-127.0.0.1] '/login3' >> LoginAction.login3(...) : void | @Ok(null ) @Fail(->:/fail) | by 0 Filters | (I:UTF-8/O:UTF-8)
16-1-21 20:37:0.736 INFO [RMI TCP Connection(3)-127.0.0.1] Create Module obj without Ioc --> class com.kanq.demo3.MainModule
16-1-21 20:37:0.736 DEBUG [RMI TCP Connection(3)-127.0.0.1] '/fail' >> MainModule.fail(...) : void | @Ok(null ) @Fail(->:/fail) | by 0 Filters | (I:UTF-8/O:UTF-8)
16-1-21 20:37:0.737 INFO [RMI TCP Connection(3)-127.0.0.1] Found 4 module methods
16-1-21 20:37:0.738 DEBUG [RMI TCP Connection(3)-127.0.0.1] @Localization not define
16-1-21 20:37:0.740 INFO [RMI TCP Connection(3)-127.0.0.1] Nutz.Mvc[nutz] is up in 275ms

你没发现里面有WARN吗?

16-1-21 20:37:0.722 WARN [RMI TCP Connection(3)-127.0.0.1] Moudle with @InjectName('loginAction') or @IocBean('loginAction') but no such ioc bean found!! Pls check your ioc configure!!

你的IocBy写错了,应该类似这样

@IocBy(type=org.nutz.mvc.ioc.provider.ComboIocProvider, args={
						"*json", "com/kanq/demo3/nutz-content.js",
						"*anno", "com/kanq"})
@IocBy(type=org.nutz.mvc.ioc.provider.ComboIocProvider, args={
						"*json", "com/kanq/demo3/nutz-content.js",
						"*anno", "com.kanq"})
添加回复
请先登陆
回到顶部