如何在jsp中拉出选定的单选按钮
我有两个单选按钮,根据选择的单选按钮,我想将它们发送到特定的 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";
}
}
}
I have two radio buttons, and depending on which one is selected I want to send them to a specific jsp page. I do not know how to pull which button is selected in my java class.
Here is the 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>
here is the 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";
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 servlet 中,确定选择了哪个按钮
您将获得该值。如果您检查包,该值将是“packages”。单选组返回一个检查值。
In the servlet, to determine which button is selected
You will get the value. If you check packages, the value will be "packages". Radio group return one checked value.