how to pull selected radio button in a jsp(如何在jsp中拉取选定的单选按钮)
问题描述
我有两个单选按钮,根据选择的一个,我想将它们发送到特定的 jsp 页面.我不知道如何在我的 java 类中选择哪个按钮.
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.
这里是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中,判断选择哪个按钮
In the servlet, to determine which button is selected
String value = request.getParameter("radio1");
您将获得价值.如果您检查包,该值将是包".单选组返回一个选中的值.
You will get the value. If you check packages, the value will be "packages". Radio group return one checked value.
这篇关于如何在jsp中拉取选定的单选按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在jsp中拉取选定的单选按钮
基础教程推荐
- 如何对 Java Hashmap 中的值求和 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- Struts2 URL 无法访问 2022-01-01
- 修改 void 函数的输入参数,然后读取 2022-01-01
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
- RabbitMQ:消息保持“未确认"; 2022-01-01
- 存储 20 位数字的数据类型 2022-01-01
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- 使用堆栈算法进行括号/括号匹配 2022-01-01
