javaweb九九乘法表
时间: 2023-09-13 09:09:27 浏览: 97
可以的,以下是JavaWeb打印九九乘法表的代码:
```java
public class MultiplicationTableServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setCharacterEncoding("UTF-8");
response.getWriter().println("<html>");
response.getWriter().println("<body>");
response.getWriter().println("<table border=\"1\">");
for (int i = 1; i <= 9; i++) {
response.getWriter().println("<tr>");
for (int j = 1; j <= i; j++) {
response.getWriter().println("<td>" + j + "*" + i + "=" + (i * j) + "</td>");
}
response.getWriter().println("</tr>");
}
response.getWriter().println("</table>");
response.getWriter().println("</body>");
response.getWriter().println("</html>");
}
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request, response);
}
}
```
阅读全文