开发者社区> 问答> 正文

struts 找不到action 方法 明明有该方法?报错

包结构图:

报错:


struts.xml


OGNLAction中有execute()方法:


可是问题是,总是找不到该方法是为什么啊?究竟是哪里错了啊?

展开
收起
爱吃鱼的程序员 2020-06-14 16:20:49 685 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB
    配置文件上面,写上method="execute"或者你的action继承actionsupport,然后重写execute方法,Struts会默认找他的 我写了之后还是报这个错的

    execute方法返回值呢

    把方法定义贴出来

    已经贴出来,你看出来哪里有问题了吗publicStringexecute()throwsException
    {
    //获取request,并添加信息
    HttpServletRequestrequest=ServletActionContext.getRequest();
    request.setAttribute("name",getName());
    //获取session,并添加信息
    Map<String,Object>session=ActionContext.getContext().getSession();
    session.put("name",getName());
    //获取application,并添加信息
    Map<String,Object>application=ActionContext.getContext().getApplication();
    application.put("name",getName());
    return"success";
    }
    方法没错误,你把整个异常堆栈贴出来看看,有可能执行方法中就出错了异常堆栈是指strutsdebug看到的信息吗?我贴出来了

    这是Strutsdebug的信息,你是指这个吗?

    不是这个是java报的异常堆栈那要怎么看,这个错误是在点击“注册”之后进行页面跳转的时候报的错误,无法进行debug。而且我再OGNLAction.java中打断点的时候,也没有执行到,我无法用debug的方式去查看堆栈信息,请问下怎么去看堆栈信息??

    这个的全部信息

    贴出来了,麻烦您帮我看看是什么原因呀? java.lang.NoSuchMethodException:ognl.OGNLAction.execute()
    ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1246)ognl.ObjectMethodAccessor.callMethod(ObjectMethodAccessor.java:68)com.opensymphony.xwork2.ognl.accessor.XWorkMethodAccessor.callMethodWithDebugInfo(XWorkMethodAccessor.java:117)com.opensymphony.xwork2.ognl.accessor.XWorkMethodAccessor.callMethod(XWorkMethodAccessor.java:108)ognl.OgnlRuntime.callMethod(OgnlRuntime.java:1369)ognl.ASTMethod.getValueBody(ASTMethod.java:90)ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:212)ognl.SimpleNode.getValue(SimpleNode.java:258)ognl.Ognl.getValue(Ognl.java:494)ognl.Ognl.getValue(Ognl.java:458)com.opensymphony.xwork2.ognl.OgnlUtil$2.execute(OgnlUtil.java:309)com.opensymphony.xwork2.ognl.OgnlUtil.compileAndExecute(OgnlUtil.java:340)com.opensymphony.xwork2.ognl.OgnlUtil.getValue(OgnlUtil.java:307)com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:423)com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:287)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:250)org.apache.struts2.interceptor.DeprecationInterceptor.intercept(DeprecationInterceptor.java:41)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:256)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:167)com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:265)org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:76)com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:138)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:229)com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:229)com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:191)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:73)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)org.apache.struts2.interceptor.DateTextFieldInterceptor.intercept(DateTextFieldInterceptor.java:125)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:91)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:253)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171)com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:139)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:193)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:189)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:564)org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:81)org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606)org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)java.lang.Thread.run(Thread.java:744)

    1.你在action里的进入和离开的时候加个trycatch.,catch输出下log

    2.你的action继承struts的actionsupport了么?...

    3.包名真逗.换个不行?

    4.execute里面写的太逗了...

    5.如果用注解就简单多了.哇嘎嘎.

    还是不行
    2020-06-14 16:21:05
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载