我有两个单选按钮,根据选择的单选按钮,我希望将它们发送到特定的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";
}
}
}
1条答案
按热度按时间sd2nnvve1#
在servlet中,确定选择了哪个按钮
你会得到价值。如果检查包,则值将为“packages”。无线组返回一个选中值。