1.消费总和
<%@ page import="java.util.regex.Pattern" %> <%@ page import="java.util.regex.Matcher" %><%-- Created by IntelliJ IDEA. User: 86177 Date: 2021/3/17 Time: 11:38 To change this template use File | Settings | File Templates. --%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <title>消费总和</title> </head> <style> body{ background: black; } </style> <%! public double getPriceSum(String input){ Pattern pattern; Matcher matcher; String regx="-?[0-9][0-9]*[.]?[0-9]*"; pattern=Pattern.compile(regx); matcher=pattern.matcher(input); double sum=0; while (matcher.find()){ String str=matcher.group(); sum+=Double.parseDouble(str); } return sum; } %> <body> <p style="font-family: 黑体;font-size:20px;color: aqua"> <span style="color: red">孙何伟</span>的菜单 <br> <% String str="麻婆豆腐:20.6元,红烧肉:68.9元"; %> <br><%=str%> <br> <br>消费总和: <span style="color: chartreuse"><%= getPriceSum(str)%></span>元 </p> <hr size="4"> <p style="font-family: 黑体;font-size:20px;color: pink"> <span style="color: red">sun he wei is sb</span>的菜单 <br> <% str="剁椒鱼头:62.9元,烤鸭:199元,红焖大虾:288.9元"; %> <br><%=str%> <br> <br>消费总和: <span style="color: chartreuse"><%= getPriceSum(str)%></span>元 </p> </body> </html>
2.日期时间
<%@ page import="java.util.Date" %> <%@ page import="java.text.SimpleDateFormat" %><%-- Created by IntelliJ IDEA. User: 86177 Date: 2021/3/17 Time: 11:38 To change this template use File | Settings | File Templates. --%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <title>日期时间</title> </head> <% Date date=new Date(); SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String time=sdf.format(date); %> <body> <h1>显示访问页面的时期、时间</h1> <p style="color: black;font-size: 35px">(服务器端的日期、时间)</p> <p style="font-size: 20px;font-weight: 700">用户在 <span style="color: red"><%=time%></span> 访问了该网页。</p> </body> </html>
3.听英语
<%-- Created by IntelliJ IDEA. User: 86177 Date: 2021/3/17 Time: 11:38 To change this template use File | Settings | File Templates. --%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <title>听英语</title> </head> <style> body{ background: black; color: aqua; } </style> <body> 英文课文(English Text): <br> <p style="font-family: 宋体;font-size: 18px;color: azure"> <jsp:include page="english/english.text" flush="true"/> 课文音频(English Audio):<br> <jsp:include page="audio.jsp"/> </p> </body> </html>
<%-- Created by IntelliJ IDEA. User: 86177 Date: 2021/3/17 Time: 12:57 To change this template use File | Settings | File Templates. --%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <title>Title</title> </head> <style> body{ /*background: black;*/ } </style> <body> <embed src="english/CMJ%20-%20所念皆星河.mp3" autostart="flase"> 课文音频在左边 </embed> </body> </html>