当前位置:编程学习 > JAVA >>

SHH2入门测试项目java.lang.NoSuchMethodError: com.aaa.service.testService.countServic错误

java.lang.reflect.InvocationTargetException
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:452)
com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:291)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:254)
com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:176)
         后面一节省略....

root cause 

java.lang.NoSuchMethodError: com.aaa.service.testService.countService()V
com.aaa.sturts.actions.testaction.count(testaction.java:38)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:452)
com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:291)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:254)
com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:176)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:263)
org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
后面一节省略...
配置文件都没错tomcat运行没问题
运行index.jsp没错
其中代码:
      ...
        <body>
    <form action="action" method="post">
    <input type="text" size="5" name="clazz">
    <input type="button" value="点击" onclick="this.form.submit();">
    </form>
  </body>
...
点击按钮跳转就出错了
action代码testaction.jsp

import com.opensymphony.xwork2.ActionSupport;

public class testaction extends ActionSupport{

/**
 * @param args
 */
private String clazz;

testService service;

public String getClazz() {
return clazz;
}
public void setClazz(String clazz) {
this.clazz = clazz;
}
public void setService(testService service) {
this.service = service;
}




public String count(){
System.out.println(clazz);
service.countService();
return "result";
}

}
testService .jsp代码:
package com.aaa.service;

import com.aaa.DAO.BaseDAOImpl;

public class testService {

/**
 * @param args
 */
BaseDAOImpl dao;
public BaseDAOImpl getDao() {
return dao;
}
public void setDao(BaseDAOImpl dao) {
this.dao = dao;
}
public void countService(){
 dao.test();
}

}
BaseDAOImpl .jsp
中test方法:
public void test(){
System.out.println("124343546");

}
求助啊...整了两天了  急啊..... --------------------编程问答-------------------- 看看你spring和struts的相关配置 --------------------编程问答-------------------- 没有用struts.xml的配置文件吗? --------------------编程问答-------------------- public String count(){
System.out.println(clazz);
service.countService();
return "result";
}

是進入count方法后才報的找不到countService方法,看看service對象類中有沒有定義好,及其他各種定義 --------------------编程问答-------------------- <body>
   <form action="action" method="post">
   <input type="text" size="5" name="clazz">
   <input type="button" value="点击" onclick="this.form.submit();">
   </form>
   </body>
form中的action中的参数,是你配置文件中action的标示吗? --------------------编程问答-------------------- 严重怀疑楼主的testService类文件没有更新,可能countService()是后加的,但重新编译后的class没有update
补充:Java ,  Web 开发
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,