truts2-Struts中Method方法无效

问题描述

Struts中Method方法无效

struts.xml

<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">

<package name="default"  extends="struts-default">
    <action name="insert" class="com.miaowublog.action.QuesAction"  method="index">
        <result name="success">/index.jsp</result>

    </action>
</package>

错误内容
java.lang.NoSuchMethodException: com.miaowublog.action.QuesAction.create()
at java.lang.Class.getMethod(Class.java:1665)
at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.getActionMethod(AnnotationValidationInterceptor.java:75)
at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:47)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.rest.RestActionInvocation.invoke(RestActionInvocation.java:138)
at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:138)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.rest.RestActionInvocation.invoke(RestActionInvocation.java:138)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:254)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.rest.RestActionInvocation.invoke(RestActionInvocation.java:138)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:254)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.rest.RestActionInvocation.invoke(RestActionInvocation.java:138)
at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:191)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.rest.RestActionInvocation.invoke(RestActionInvocation.java:138)
at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:73)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.rest.RestActionInvocation.invoke(RestActionInvocation.java:138)
at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:91)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.rest.RestActionInvocation.invoke(RestActionInvocation.java:138)
at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:252)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.rest.RestActionInvocation.invoke(RestActionInvocation.java:138)
at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.rest.RestActionInvocation.invoke(RestActionInvocation.java:138)
at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.rest.RestActionInvocation.invoke(RestActionInvocation.java:138)
at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.rest.RestActionInvocation.invoke(RestActionInvocation.java:138)
at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.rest.RestActionInvocation.invoke(RestActionInvocation.java:138)
at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:139)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.rest.RestActionInvocation.invoke(RestActionInvocation.java:138)
at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.rest.RestActionInvocation.invoke(RestActionInvocation.java:138)
at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:193)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.rest.RestActionInvocation.invoke(RestActionInvocation.java:138)
at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:189)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.rest.RestActionInvocation.invoke(RestActionInvocation.java:138)
at com.opensymphony.xwork2.DefaultActionProxy.execute(DefaultActionProxy.java:147)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:562)
at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:999)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:565)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)

对应的Action
public class QuesAction {

private Quesbean qu;

public Quesbean getQu() {
    return qu;
}

public void setQu(Quesbean qu) {
    this.qu = qu;
}

public String index(){
    System.out.println(qu);

    return "success";
}

/*public String create(){

    System.out.println(qu);

    return "success";
}*/

}

问题为:不知道是怎样的原因,method属性失效,Struts强制性的制定方法名,并且动态调用的方法也只找其强制制定的方法。求解决办法

解决方案

http://blog.csdn.net/csh624366188/article/details/6963634

时间: 2024-09-21 16:19:18

truts2-Struts中Method方法无效的相关文章

struts中动态方法调用使用通配符_java

一.DMI动态方法调用的其中一种改变form表单中action属性的方式已经讲过了.还有两种,一种是改变struts.xml配置文件中action标签中的method属性,来指定执行不同的方法处理不同的业务逻辑:另外一种是使用通配符的方式.改变method属性的方式需要配置多个action,而且这些action定义的绝大部分都是相同的,所以这种定义是相当冗余的.因此,使用通配符就可以在一个action标签中代替多个逻辑处理的Action. 二.示范:(和之前的动态方法调用改变form表单acti

在Struts中对用户输入信息的校验方法对比:validate 和validator

在Struts中对用户输入信息的校验一般在FromBean中进行(除非需要访问数据库进行诸如登录信息的校验,因为这是Action的工作),本文将阐述如何在Struts中实现可配置的信息校验. 一.在FormBean中手工实现 最简单的方法是直接在FormBean中重写ActionForm类的validate方法,validate方法签名如下: public ActionErrors validate(ActionMapping mapping, HttpServletRequest req) 比

Struts中使用validate()输入校验方法详解_java

1.在ActionSupport中有一个validate()方法,这个方法是验证方法,它会在execute()方法执行之前执行,所以能够起到很好的验证的作用. @Override //重写Action中的validate()方法 public void validate() { if(null==this.username||this.username.length()<4||this.username.length()>6){ this.addActionError("userna

Json在Struts中的转换与传递方法_java

本文主要探讨普通数据如何快速转换为Json数据,一共讨论2种方法: 首相准备页面和实体类: 页面: <body> <div id="topLoginDiv"> 用户名: <input name="user.name" id="loginName" />  密码: <input name="user.password" id="loginPassword" />

asi重定向问题-iPhone开发中网络请求重定向多次后,重定向方法无效

问题描述 iPhone开发中网络请求重定向多次后,重定向方法无效 在做登陆功能的时候,发送了post请求网址是url,登陆成功后,会返回个新的newurl,在对newurl请求就ok,但是 登陆成功了几次后(正确的用户和密码),在登陆就不能触发请求了,其他的请求也不能触发,这是为什么??不仅仅是登陆这块的重定向请求,其他功能也有重定向请求,只要请求重定向了,累加3次 其他的网络请求就不能被触发,求解!!!急求 解决方案 http://www.hackhome.com/InfoView/Artic

js文件-jsp中引用js的方法无效

问题描述 jsp中引用js的方法无效 js文件里的function function checkNum(){ var num1 = document.getElementById("num1").value; var num2 = doucment.getElementById("num2").value; if(num1=="" || num2==""){ alert("输入不能为空"); return

js中style.display=&quot;&quot;无效的解决方法_javascript技巧

本文实例讲述了js中style.display=""无效的解决方法.分享给大家供大家参考.具体解决方法如下: 一.问题描述: 在js中我们有时想动态的控制一个div显示或隐藏或更多的操作,但如果我们style.display=""可能导致没有效果. 看下面一段代码: 复制代码 代码如下: <style>  #name  {      display:none;  } </style> </head> <body> &l

简化繁琐的赋值——反射在Jdbc和Struts中的应用

缘起在Jdbc应用中,我们经常需要有这么样的一个Javabean:当我们从数据库里取值时,我们希望把对应的值赋给Javabean,而后再操作Javabean进行各种业务处理:而我们保存数据的时候,也希望把经过业务处理后的值赋给Javabean,再由该Javabean与Jdbc交互,将数据保存在数据库里. 而在Struts应用中,我们经常要跟ActionForm或DynaActionForm打交道,例如从业面取得用户输入的数据,在Struts应用中,我们实际上是从ActionForm中取得数据:而

struts2中action中的方法无故被提交两次

问题描述 struts2中action中的方法无故被提交两次 import java.io.UnsupportedEncodingException; import javax.servlet.http.HttpServletRequest; import org.apache.struts2.ServletActionContext; import com.hsp.book.domain.Book;import com.hsp.book.service.BookService;import c