NutzCN Logo
问答 @SLog中的${args[1].getAttribute('hotwordName')}好像获取不到,
发布于 2886天前 作者 qq_7060b743 2018 次浏览 复制 上一个帖子 下一个帖子
标签: nutzwk

具体代码如下
@At
@Ok("json")
@RequiresPermissions("hotword.manage.add")
@SLog(tag = "添加热门词汇", msg = "关键词:${args[1].getAttribute('hotwordName')}")
public Object add(@Param("hotwordName") String name,@Param("hotOrder") String hotOrder,HttpServletRequest req) {
try{
Api_hotWord fristWord = hotwordService.fetch(1);
if(fristWord==null){
fristWord=new Api_hotWord();
fristWord.setHid(1);
fristWord.setName(name);
fristWord.setHotOrder(Integer.parseInt(hotOrder));
fristWord.setCreteDate(new Date());
fristWord.setUpdateDate(new Date());
hotwordService.insert(fristWord);
}else {
fristWord.setName(name);
fristWord.setHotOrder(Integer.parseInt(hotOrder));
fristWord.setUpdateDate(new Date());
hotwordService.updateIgnoreNull(fristWord);
}
req.setAttribute("hotwordName", hotwordService.fetch(1).getName());
return Result.success("system.success");
} catch (Exception e) {
return Result.error("system.error");
}
}
}
```报的错如下

org.nutz.lang.InvokingException: Don't know how to invoke [java.lang.String].getAttribute() by args:
 hotwordName
	at org.nutz.lang.Invoking.<init>(Invoking.java:159)
	at org.nutz.lang.Mirror.getInvoking(Mirror.java:1023)
	at org.nutz.lang.Mirror.invoke(Mirror.java:1100)
	at org.nutz.el.opt.object.AccessOpt.run(AccessOpt.java:71)
	at org.nutz.el.opt.object.MethodOpt.calculate(MethodOpt.java:48)
	at org.nutz.el.opt.object.InvokeMethodOpt.calculate(InvokeMethodOpt.java:22)
	at org.nutz.el.arithmetic.RPN.calculate(RPN.java:55)
	at org.nutz.el.arithmetic.RPN.calculate(RPN.java:38)
	at org.nutz.el.El.eval(El.java:30)
	at cn.wizzer.common.services.log.SysLogAopInterceptor.doLog(SysLogAopInterceptor.java:76)
	at cn.wizzer.common.services.log.SysLogAopInterceptor.filter(SysLogAopInterceptor.java:60)
	at org.nutz.aop.InterceptorChain.doChain(InterceptorChain.java:60)
	at cn.wizzer.modules.back.api.controller.HotwordController$$NUTZAOP.add(HotwordController.java:1)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.nutz.mvc.impl.processor.MethodInvokeProcessor.process(MethodInvokeProcessor.java:25)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.AdaptorProcessor.process(AdaptorProcessor.java:33)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.ActionFiltersProcessor.process(ActionFiltersProcessor.java:58)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at cn.wizzer.common.processor.XssSqlFilterProcessor.process(XssSqlFilterProcessor.java:35)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at cn.wizzer.common.processor.NutShiroProcessor.process(NutShiroProcessor.java:52)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:123)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.EncodingProcessor.process(EncodingProcessor.java:27)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.UpdateRequestAttributesProcessor.process(UpdateRequestAttributesProcessor.java:15)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at cn.wizzer.common.processor.GlobalsSettingProcessor.process(GlobalsSettingProcessor.java:37)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at cn.wizzer.common.processor.LogTimeProcessor.process(LogTimeProcessor.java:21)
	at org.nutz.mvc.impl.NutActionChain.doChain(NutActionChain.java:44)
	at org.nutz.mvc.impl.ActionInvoker.invoke(ActionInvoker.java:67)
	at org.nutz.mvc.ActionHandler.handle(ActionHandler.java:31)
	at org.nutz.mvc.NutFilter.doFilter(NutFilter.java:198)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
	at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61)
	at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
	at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
	at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
	at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
	at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
	at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
	at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
	at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
	at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)
	at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
	at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:528)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1100)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:687)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1520)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1476)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Unknown Source)

我感觉就是我的@SLog(tag = "添加热门词汇", msg = "关键词:${args[1].getAttribute('hotwordName')}")这个有问题,但是我并不会改

3 回复

0、1、2,自己数下下标是几?。。

竟然是2,我之前一直在0和1哪里整,谢谢了

其实呢, 上下文里面多放个req和resp就没这样的烦恼了嘛

添加回复
请先登陆
回到顶部