struts2双重提交问题

发布于 2024-09-10 18:27:15 字数 115 浏览 3 评论 0原文

我使用的是struts2.1.8。这里我想处理双重提交。 truts2提供了TokenInterceptor。因此,如果我提交两次,它会返回“invalid.token”作为结果名称。但我想显示我提交两次的同一页面。

I am using struts2.1.8. Here I want to handle double submission.
truts2 provides TokenInterceptor. So if I submitted two times, it returns "invalid.token" as a result name. But I want to display the same page from which I have submitted twice.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

好听的两个字的网名 2024-09-17 18:27:15

由于您想要显示双重提交的同一页面,因此您需要在每个 定义中创建一个 invalid.token 结果。试图防止重复提交:

<action name="some-action" class="foo.Bar">
    <interceptor-ref name="token"/> 
    <result name="success">/WEB-INF/some/action/success.jsp</result>
    <result name="invalid.token">/WEB-INF/some/action/input.jsp</result>
</action>

文档提供更多信息,您可能还想考虑查看 令牌会话拦截器

Since you want to display the same page that you double-submitted from, you'll need to create an invalid.token result in each of the <action> definitions you're trying to prevent double submission from:

<action name="some-action" class="foo.Bar">
    <interceptor-ref name="token"/> 
    <result name="success">/WEB-INF/some/action/success.jsp</result>
    <result name="invalid.token">/WEB-INF/some/action/input.jsp</result>
</action>

The docs provide more info and you might also want to consider looking into the Token Session Interceptor.

べ繥欢鉨o。 2024-09-17 18:27:15

您的应用程序中是否需要双重提交功能?

如果要防止重复提交问题,最好实现“Post 后重定向”模式,请参阅以下两个链接以获取详细说明:

http://www.theserverside.com/news/1365146/Redirect-After-Post

http://en.wikipedia.org/wiki/Post/Redirect/Get

Is double submission required functionality in your application?

If you want to prevent double submit problems it is better to implement the Redirect after Post pattern, see the following two links for a detailed explanation:

http://www.theserverside.com/news/1365146/Redirect-After-Post

http://en.wikipedia.org/wiki/Post/Redirect/Get

好多鱼好多余 2024-09-17 18:27:15

查看TokenSessionInterceptor,它建立在 TokenInterceptor。来自文档:

与普通的令牌拦截器不同,
该拦截器将尝试
提供智能故障转移
使用多个请求的事件
同一次会议。也就是说,它会阻塞
后续请求直到第一个请求
请求完成,然后改为
返回 invalid.token 代码,
它将尝试显示相同的内容
回复原件,有效
动作调用会显示
如果没有提交多个请求
首先。

Look at the TokenSessionInterceptor, which builds upon the TokenInterceptor. From the docs:

Unlike the normal token interceptor,
this interceptor will attempt to
provide intelligent fail-over in the
event of multiple requests using the
same session. That is, it will block
subsequent requests until the first
request is complete, and then instead
of returning the invalid.token code,
it will attempt to display the same
response that the original, valid
action invocation would have displayed
if no multiple requests were submitted
in the first place.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文