Odd results with get vs post for an action and form

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Odd results with get vs post for an action and form

Dave Weis
Hello

I'm having an odd problem trying to make a simple form that submits to an
action. If I set the method in the form to "get" it works fine but if I
leave it to default to "post" I receive the following error.

Thanks for any help
dave

-----------------------------------

ERROR Dispatcher Could not find action or result: /learnstruts2/dave
 Method create for action dave is not allowed! - [unknown location]
at
com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:206)
at
com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:74)
at
org.apache.struts2.rest.RestActionProxyFactory.createActionProxy(RestActionProxyFactory.java:53)
at
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:567)
at
org.apache.struts2.dispatcher.ExecuteOperations.executeAction(ExecuteOperations.java:81)
at
org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:143)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:475)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
at
org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:651)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
at
org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:500)
at
org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at
org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:754)
at
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1376)
at
org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
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)

-------------------------------------

<s:form action="dave">
  <s:textfield name="userName" label="Your name" />
  <s:submit />
</s:form>

-------------------------------------

package com.sjdjweis.learnstruts;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionSupport;

/**
 * @author djweis
 *
 */
public class DaveAction extends ActionSupport {
private static final long serialVersionUID = 1L;
public String index() {
return Action.SUCCESS;
}

public void setUserName(String userName) {
}
public String getUserName() {
return "theusername";
}
}

--------------------------------

    <action name="dave" class="com.sjdjweis.learnstruts.DaveAction">
    <result name="success">/dave.jsp</result>
    </action>

------------------------------------

Struts Problem Report

Struts has detected an unhandled exception:
*Messages*:
- Method create for action dave is not allowed!
------------------------------
Stacktraces
*Method create for action dave is not allowed! - [unknown location]*

    com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:206)
    com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:74)
    org.apache.struts2.rest.RestActionProxyFactory.createActionProxy(RestActionProxyFactory.java:53)
    org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:567)
    org.apache.struts2.dispatcher.ExecuteOperations.executeAction(ExecuteOperations.java:81)
    org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:143)
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
    org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:475)
    org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
    org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:651)
    org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
    org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:500)
    org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:754)
    org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1376)
    org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    java.lang.Thread.run(Unknown Source)
Reply | Threaded
Open this post in threaded view
|

Re: Odd results with get vs post for an action and form

Yasser Zamani


On 10/15/2017 4:23 AM, Dave Weis wrote:
> If I set the method in the form to "get" it works fine but if I
> leave it to default to "post" I receive the following error.

It seems you have REST Plugin in your box and when you use http post
method, Struts looks for a method named `create` on your action to
execute it, but cannot find any and cries ;)

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Odd results with get vs post for an action and form

Dave Weis
On Sun, Oct 15, 2017 at 1:30 AM, Yasser Zamani <[hidden email]>
wrote:
>
> On 10/15/2017 4:23 AM, Dave Weis wrote:
> > If I set the method in the form to "get" it works fine but if I
> > leave it to default to "post" I receive the following error.
>
> It seems you have REST Plugin in your box and when you use http post
> method, Struts looks for a method named `create` on your action to
> execute it, but cannot find any and cries ;)
>

That did it, thank you!

dave