GET submits instead of POST ones. Tapestry

2019-05-17 06:19发布

I've encountered this problem in tapestry 5.2 application:

Forms require that the request method be POST and that the t:formdata query parameter have values.

In access log, i found that sometimes there are form submits with GET method from different users. Though, according to docs, Tapestry 5 use post-redirect-get scheme. This page doesn't allow anonymous access, so it can't be robots. So i,m frustrated what can be the cause of such issue. Suggestions please.

There is couple of selects, refreshed by Ajax, on the form.

Edit 2. Such GET request came from users not bots, because there was successful logins from that ips.

3条回答
forever°为你锁心
2楼-- · 2019-05-17 07:01

I notice that the form component has the following:

Object onAction(EventContext context) throws IOException {
   ...
   executeStoredActions();
   ...
}

private void executeStoredActions()
{
    String[] values = request.getParameters(FORM_DATA);

    if (!request.getMethod().equals("POST") || values == null)
        throw new RuntimeException(messages.format("invalid-request", FORM_DATA));
    }
    ...
}

This means that it will handle all "action" events from itself and any nested components. I don't suppose you've got a nested component firing the "action" event (eg actionlink) and not handling/aborting the event? These events would "bubble up" to the form handler and cause the error.

See here for reasons why an event might "bubble up".

查看更多
相关推荐>>
3楼-- · 2019-05-17 07:05

I'm going to take a guess and say it's a web-crawler crawling your production site. You might want to customise tapestry's exception handling to hide exceptions from web-crawlers.

You can usually detect web-crawlers via the user agent request header.

See here for a list of known bots.

查看更多
女痞
4楼-- · 2019-05-17 07:17

This is an old question, but in case anyone else stumbles upon it in a search... you can "decorate" Tapestry's RequestExceptionHandler to catch this exception and redirect the user to the page they probably wanted.

See the Tapestry Specific Errors FAQ for the code to implement this:

https://tapestry.apache.org/specific-errors-faq.html

查看更多
登录 后发表回答