java.lang.NoSuchMethodException 错误
报错:
Stacktraces
java.lang.Class.getMethod(Class.java:1607) org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.getActionMethod(AnnotationValidationInterceptor.java:75) org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:47) com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:133) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207) com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207) com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:190) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:243) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:142) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:166) com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:176) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:190) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52) org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:485) org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77) org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91) 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:102) org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293) org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:877) org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:594) org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1675) java.lang.Thread.run(Thread.java:662)
action代码
package com.gssw.action; import java.util.List; import com.gssw.dao.ProDao; import com.gssw.dao.ProTypeDao; import com.gssw.pojo.Product; import com.gssw.pojo.ProductType; import com.gssw.util.Pager; import com.opensymphony.xwork2.ActionSupport; import com.opensymphony.xwork2.ModelDriven; public class ProAction extends ActionSupport implements ModelDriven<Product>{ private static final long serialVersionUID = 1L; private Product pro=new Product(); private List<ProductType> proType; private List<Product> pros; private String op; private Pager<Product> proPager=new Pager<Product>(); private String pno; @Override public Product getModel() { return pro; } /* public ProAction() { proType=pto.read(); } */ //private UserDao udo; private ProDao pdo; private ProTypeDao pto; public String list() throws Exception{ proType=pto.read(); //提供总记录数的 proPager.setRecordCount(pdo.total()); proPager.setPageSize(5); proPager.setPageNo(pno); pros=pdo.read(proPager.getPageNo(), proPager.getPageSize(), "proName desc,proId desc"); proPager.setData(pros); proPager.setUrl("pro_list.action"); return "list"; } public String create(){ op="create"; return "input"; } public String updata(){ op="updata"; //这里要读一下数据库页面只是返回了一个id的值 pro=pdo.read(pro.getProId()); return "input"; } public String createOrUpdata() throws Exception{ System.out.println(pro.toString()); if("create".equals(op)){ pdo.create(pro); } else if("updata".equals(op)){ pdo.update(pro); } return list(); } public String delete() throws Exception{ pdo.delete((int) pro.getProId()); return list(); } //set();get(); public List<ProductType> getProType() { return proType; } public void setProType(List<ProductType> proType) { this.proType = proType; } public List<Product> getPros() { return pros; } public void setPros(List<Product> pros) { this.pros = pros; } public String getOp() { return op; } public void setOp(String op) { this.op = op; } public String getPno() { return pno; } public void setPno(String pno) { this.pno = pno; } public Product getPro() { return pro; } public Pager<Product> getProPager() { return proPager; } public void setProPager(Pager<Product> proPager) { this.proPager = proPager; } /* DI */ public void setPdo(ProDao pdo) { this.pdo = pdo; } public void setPto(ProTypeDao pto) { this.pto = pto; } }
struts.xml
<struts> <constant name="struts.devMode" value="true" /> <!-- 使用最简单主题,防止生成一些不需要的标签 --> <constant name="struts.ui.theme" value="simple" /> <!-- struts2不拦截kindeditor在线编辑器中的jsp --> <constant name="struts.action.excludePattern" value="/kindeditor/jsp/.*" /> <!-- spring插件整合Struts2 --> <constant name="struts.objectFactory" value="org.apache.struts2.spring.StrutsSpringObjectFactory" /> <package name="default" namespace="/" extends="struts-default"> <default-action-ref name="default" /> <global-results> <result name="login" type="redirect">/admin/login.jsp</result> <result name="index">/index.jsp</result> </global-results> <action name="log*" class="logopaction" method="log{1}"> <result name="reindex" type="redirect">/admin/pro_list.action</result> <result name="input">/admin/login.jsp</result> </action> <action name="pro_*" class="proaction" method="{1}"> <result name="list">/admin/pages/dept/list.jsp</result> <result name="input">/admin/pages/dept/${op}.jsp</result> </action> <action name="default"> <result type="redirect">/admin/login.jsp</result> </action> </package> </struts>
update.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> <%@ taglib uri="/struts-tags" prefix="s" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> <style type="text/css"> #error { color: red; } </style> </head> <body> <div id="content"> <h1 class="title">修改产品</h1> <div id="error"> <c:forEach items="${errors }" var="error"> <li>${error.value[0] }</li> </c:forEach> </div> <div id="input"> <form method="post" action="pro_createOrUpdate.action"> <input type="hidden" name="op" value="update"> <input type="hidden" name="proId" value="${pro.proId }"> <ul> <li> <label>proName</label> <input type="text" name="proName" value="${pro.proName }"> </li> <li> <label>proPrice</label> <input type="text" name="proPrice" value="${pro.proPrice }"> </li> <li> <label>proNum</label> <input type="text" name="proNum" value="${pro.proNum }"> </li> <li> <input type="submit" value="保存"> <input type="button" value="取消" onclick="location.href=‘pro_list.action‘"> </li> </ul> </form> </div> </div> </body> </html>
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。