base.jsp

<%@ page language="java" import="java.util.*" contentType="text/html; charset=utf-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
String projectPath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path;
String staticPath = projectPath + "/static";
String imagePath = projectPath + "/uploads";
%>
<%--项目路径 --%>
<c:set var="basePath" value="<%=projectPath%>"></c:set>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<%--静态资源路径 --%>
<c:set var="ctxsta" value="${pageContext.request.contextPath}/static"/>
<%--页面显示图片的前缀路径--%>
<c:set var="ctximg" value="${pageContext.request.contextPath}/uploads"/>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,我理解了你的问题。首先,我们需要创建三个JSP页面,分别是main.jsp、circle.jsp和ladder.jsp。下面是这三个页面的代码实现: main.jsp ``` <html> <head> <title>Main Page</title> </head> <body> <h1>Main Page</h1> <jsp:include page="circle.jsp"> <jsp:param name="radius" value="5"/> </jsp:include> <br> <jsp:include page="ladder.jsp"> <jsp:param name="upper" value="10"/> <jsp:param name="lower" value="15"/> <jsp:param name="height" value="8"/> </jsp:include> </body> </html> ``` circle.jsp ``` <%@ page language="java" %> <%@ page import="java.text.DecimalFormat" %> <% double radius = Double.parseDouble(request.getParameter("radius")); double area = Math.PI * radius * radius; DecimalFormat df = new DecimalFormat("#.##"); %> <h2>Circle Area Calculation</h2> <p>Radius: <%=radius%></p> <p>Area: <%=df.format(area)%></p> ``` ladder.jsp ``` <%@ page language="java" %> <%@ page import="java.text.DecimalFormat" %> <% double upper = Double.parseDouble(request.getParameter("upper")); double lower = Double.parseDouble(request.getParameter("lower")); double height = Double.parseDouble(request.getParameter("height")); double area = (upper + lower) * height / 2; DecimalFormat df = new DecimalFormat("#.##"); %> <h2>Ladder Area Calculation</h2> <p>Upper base: <%=upper%></p> <p>Lower base: <%=lower%></p> <p>Height: <%=height%></p> <p>Area: <%=df.format(area)%></p> ``` 在这三个页面中,我们使用了JSP中的include动作标记,来加载circle.jsp和ladder.jsp页面,并且通过param子标记提供了圆的半径以及梯形的上底、下底和高的值。在circle.jsp和ladder.jsp页面中,我们通过request.getParameter()方法获取了这些值,并计算了圆和梯形的面积。最后,我们使用DecimalFormat类对面积进行格式化,并将其显示在页面上。 请注意,这些页面应该保存在同一Web服务目录中,并且可以通过浏览器访问main.jsp页面来查看结果。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值