<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Insert title here</title> </head> <body> <div> <form action="main.jsp"> <input type="number" id="cs1" name="R" placeholder="请输入圆的半径"> <input type="submit" value="确定"> </form> </div> <% String R=request.getParameter("R"); if(R!=null){ double cr=Double.parseDouble(R); double cs=cr*cr*3.14; out.print("输入圆的半径为:"+cr+"。得出圆的面积为"+cs); request.setAttribute("cr", cr); request.setAttribute("cs", cs); } %> </body> </html>
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Insert title here</title> </head> <body> <div> <form action="main.jsp"> <input type="number" name="SD" placeholder="请输入梯形上底"> <input type="number" name="XD" placeholder="请输入梯形下底"> <input type="number" name="H" placeholder="请输入梯形的高"> <input type="submit" value="确定"> </form> </div> <% String SD=request.getParameter("SD"); String XD=request.getParameter("XD"); String H=request.getParameter("H"); if(SD!=null&&XD!=null&&H!=null){ double sd=Double.parseDouble(SD); double xd=Double.parseDouble(XD); double h=Double.parseDouble(H); double ls=(sd+xd)*h/2; out.print("输入的梯形上底、下底、高分别为:"+sd+"、"+xd+"、"+h+"。得出梯形的面积为:"+ls); request.setAttribute("sd", sd); request.setAttribute("xd", xd); request.setAttribute("h", h); request.setAttribute("ls", ls); } %> </body> </html>
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <%@ include file="circle.jsp" %> <%@ include file="ladder.jsp" %> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Insert title here</title> </head> <body> </body> </html>
来源:https://www.cnblogs.com/DOCEAN/p/12561683.html