Struts - 动作映射 - 选择选项时

发布于 2024-10-08 18:37:30 字数 337 浏览 1 评论 0原文

我目前正在做一个struts2项目。在我的项目中,用户会从数据库中存储的众多选项中随机获得 2 个选项,他可以从中选择任意一个。选中的选项被视为获胜者,未选中的选项被视为失败者。每场比赛的胜负次数都会被记录下来。这意味着我需要将获胜者和失败者都发送到操作,发送哪一个将取决于用户点击的内容。另外,我有 2 个与对象相关的工作,简单的字符串是不够的。

我不知道如何解决这个问题,因为无论我如何命名我的选项,都将是我必须在行动中给出的名称。有人可以告诉我如何获取单击的选项的名称。我的行动应该怎样做。

另外,如果希望用户在单击选项后无需单击提交按钮,我应该做什么修改?

对于上述两个问题,解决方案最好符合 OO 原则

I am currently working on a struts2 project. In my project the user is given 2 options randomly of the many stored in the database out of which he selects any 1. the option that is selected is considered the winner and the one that is not is considered loser. The number of wins and losses for each entry is noted. That means i need to send both the winner and loser to the action and which 1 is sent will depend on what the user clicks. Also i have 2 work with objects simple strings is not enough.

I don't know how to go about this because whatever i name my options will be the name i have to give in the action. can someone tell me how to get the name of the option clicked. what should i do in my actions.

also if want that the user need not click the submit button after clicking the option what modifications should i do?

For both the above questions it would be best if the solution conforms to the OO Principles

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

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

发布评论

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

评论(1

伴梦长久 2024-10-15 18:37:30

您需要采取同时处理两个选项的操作(因此无论是赢家还是输家)。或者您需要为每个请求发送多个请求(例如使用 ajax)。

You need to make an action that handles both options at the same time (So both winner or Loser). Or you need to sent multiple requests (for example with ajax) for each of them.

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