gpt4 book ai didi

java - 如何在jsp中拉出选定的单选按钮

转载 作者:行者123 更新时间:2023-12-04 06:30:31 25 4
gpt4 key购买 nike

我有两个单选按钮,根据选择的哪个,我想将它们发送到特定的 jsp 页面。我不知道如何拉出我的 java 类中选择了哪个按钮。

这是jsp:

<form method="post" action="ttp.actions.Sale1Action.action">

<input type="radio" name="radio1" value="packages"checked> packages<br>
<input type="radio" name="radio1" value="productions"> productions<br>

<input type="submit" value=" next "/>

</form>

这是java:
public class Sale2Action implements Action {

public String process(HttpServletRequest request, HttpServletResponse response) throws Exception {


String prodPack = request.getParameter("radio1");
System.out.println("radio1 = " + prodPack);
String venueID = request.getParameter("venueid");
Venue v = VenueDAO.getInstance().read(venueID);


if (prodPack.equals("packages")) {
return "sale3a.jsp";
} else {
return "sale3b.jsp";
}
}
}

最佳答案

在servlet中,判断哪个按钮被选中

String value = request.getParameter("radio1"); 

您将获得值(value)。如果您检查包,则该值将是“包”。 Radio 组返回一个选中的值。

关于java - 如何在jsp中拉出选定的单选按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5478959/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com