Struts - 动作映射 - 选择选项时
我目前正在做一个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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要采取同时处理两个选项的操作(因此无论是赢家还是输家)。或者您需要为每个请求发送多个请求(例如使用 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.