diff --git a/work/web/WEB-INF/classes/Homework.jsp b/work/web/WEB-INF/classes/Homework.jsp new file mode 100644 index 0000000000000000000000000000000000000000..490072b20c17cb6c99cb8ab1b91e0c9724fa7d04 --- /dev/null +++ b/work/web/WEB-INF/classes/Homework.jsp @@ -0,0 +1,65 @@ +<%-- + Created by IntelliJ IDEA. + User: Administrator + Date: 2024-06-02 + Time: 13:34 + To change this template use File | Settings | File Templates. +--%> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + Homework + + +<%--.定义一个Animal类,并在类中定义一个String sleep(int time)的成员方法;--%> +<%! + class Animal{ + String sleep(int time){ + return "一只动物在睡觉"; + } + } + %> +<%! + //定义一个Cat类,包含name及time的属性,并定义String sleep(int time)的方法; + class Cat{ + String name; + int time; + String sleep(int time){ + return "一只"+name+"睡觉睡了"+time+"个小时"; + } + } +%> +<% + Animal animal = new Animal(); + out.println(animal.sleep(3)); + %> +
+<% + Cat cat = new Cat(); + cat.name="汤姆猫"; + out.println(cat.sleep(8)); +%> +<%--在jsp页面中展示九九乘法口诀--%> + +<% + for (int i = 1; i <=9 ; i++) { +%> + +<% + for (int j = 1; j <=i ; j++) { +%> + + <% + } + %> + + <% + } + %> +
+ <% + out.print(i+"*"+j+"="+(i*j)); + %> +
+ +