题目内容
现定义有一servlet: exam.ShowNumber,代码如下。package exam;@WebServlet("/ShowNumber")public class ShowNumber extends HttpServlet {private static final long serialVersionUID = 1L;public void service(HttpServletRequest req, HttpServletResponse resp)throws IOException {resp.setContentType("text/html;charset=GBK");PrintWriter out = resp.getWriter();String cmd = req.getParameter("cmd");out.println("");int sum=0;if (cmd.equals("odd")) {for (int i=0;i<10;i++) {if (i % 2!=0) out.print(i+" ");}} else {for (int i=0;i<10;i++) {if (i % 3==0) {out.print(i+" ");sum += i;}}out.println("sum="+sum);}out.println("
");out.println("");}}在浏览器地址栏内输入请求:http://localhost:8080/exam/ShowNumber?cmd=, 则浏览器显示结果:( )
查看答案
搜索结果不匹配?点我反馈