zoukankan      html  css  js  c++  java
  • JSP第三次作业

    main.jsp

    <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
    <html>
    <head>
    
    </head>
    <body>
        <%!double r = 1, a = 2, b = 3, c = 4;%>
        <br>计算半径为<%=r%>的圆的面积:
        <jsp:include page="circle.jsp">
            <jsp:param value="<%=r %>" name="name3" />
        </jsp:include>
        <p>---------------------------------------------------------------------</p>
        <br>计算上底、下底、高为<%=a%>,<%=b%><%=c%>的梯形面积
        <jsp:include page="ladder.jsp">
            <jsp:param value="<%=a %>" name="name1" />
            <jsp:param value="<%=b %>" name="name2" />
            <jsp:param value="<%=c %>" name="name3" />
        </jsp:include>
    </body>
    </html>

    circle.jsp

    <%@page contentType="text/html;charset=utf-8"%>
    <%
        String sideR = request.getParameter("name3");
        double r = Double.parseDouble(sideR);
        
    %>
    <%!
    
    public String getArea(double r) {
            double area = r * r * 3.14;
            return "" + area;
        }%>
    
    <br>
    
    <br>
    圆的半径是:<%=r%>
    <br>
    圆的面积是:<%=getArea(r)%>

    ladder.jsp

    <%@page contentType="text/html;charset=utf-8"%>
    <%
        String name1 = request.getParameter("name1");
        String name2 = request.getParameter("name2");
        String name3 = request.getParameter("name3");
        double a = Double.parseDouble(name1);
        double b = Double.parseDouble(name2);
        double c = Double.parseDouble(name3);
    %>
    <%!public String getArea(double a, double b, double c) {
            double area = ((a + b) * c) / 2;
            return "" + area;
        }%>
    
    <br>
    
    <br>
    梯形的上底、下底、高是:
    <%=name1%>
    <%=name2%>
    <%=name3%>
    <br>
    梯形的面积是:
    <%=getArea(a, b, c)%>

  • 相关阅读:
    poj1191(記憶化搜索)
    poj1088(記憶化搜索)
    二叉樹鏈表
    19_高级映射:一对多查询(使用resultMap)
    18_高级映射:一对一查询(使用resultMap)
    17_高级映射:一对一查询(使用resultType)
    15_CXF和Spring开发手机号查询网站
    14_CXF发布REST服务
    13_CXF和Spring整合发布服务
    12_CXF入门
  • 原文地址:https://www.cnblogs.com/522-simple/p/12557545.html
Copyright © 2011-2022 走看看