JSP 在页面1中,输入一个图书价格,到达页面2,在页面2中输入一个折扣,提交,在页面3中显示购买所需的价格

mac2024-07-11  52

p1.jsp

<%@ 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> <form action="p2.jsp" method="post"> 图书价格: <input name="account" type="text"> <input type ="submit" value="提交"> </form> </body> </html>

p2.jsp

<%@ 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> <% String str=request.getParameter("account"); %> <form action="p3.jsp" method="post"> 折扣: <input name="discount" type="text"><br> <input type="hidden" name="b" value="<%= str %>"> <input type="submit" value="提交"> </form> </body> </html>

p3.jsp

<%@ 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> <% String str1=request.getParameter("discount"); String str2=request.getParameter("b"); %> <%= Double.parseDouble(str2)*Double.parseDouble(str1)*0.1 %> </body> </html>
最新回复(0)