62,623
社区成员
发帖
与我相关
我的任务
分享<body>
<form action="handleServlet.do">
<input type="checkbox" name="aa" value="">
<input type="checkbox" name="bb" value="">
</form>
</body>public void doPost(HttpServletRequest request, HttpServletRequest response)
throws IOException, ServletException
{
String aa=request.getParameter("aa");
String bb=request.getParameter("bb");
//下面省略相关代码,大意是如果aa选中,就怎么样怎么样
//如果bb选中就怎么样怎么样。
//我的问题是如何知道a.jsp中aa和bb有没有选中??
}<body>
<form action="a.jsp" mothed="post">
<input type="checkbox" name="aa" value="">
<input type="checkbox" name="bb" value="">
</form>
<%
String aa=request.getParameter("aa");
String bb=request.getParameter("bb");
if((aa!=""||aa!=null)&&(bb!=""||bb!=null))
System.out.println("两个都选中");
else if((aa!=""||aa!=null)&&(bb==""||bb==null))
System.out.println("aa有bb没有");
else if((aa==""||aa==null)&&(bb==""||bb==null))
System.out.println("都没有选中");
else ((aa!=""||aa!=null)&&(bb==""||bb==null))
System.out.println("aa没有bb有");
%>
</body>