• jsp第三次作业


    1.P37 实验1 消费总和

    <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
    <%@ page import="java.util.regex.Pattern"%>
    <%@ page import="java.util.regex.Matcher"%>
    
    <%!public double getPriceSum(String input) {
            Pattern pattern;
            Matcher matcher;
            String regex = "-?[0-9][0-9]*[.]?[0-9]*";
            pattern = Pattern.compile(regex);
            matcher = pattern.matcher(input);
            double sum = 0;
            while (matcher.find()) {
                String str = matcher.group();
                sum += Double.parseDouble(str);
            }
            return sum;
        }%>
    
    <html>
    <body bgcolor=cyan>
        <p style="font-family:黑体;font-size:20">
            <br>张三的菜单:
            <%
                String str = "麻婆豆腐:20.6元,红烧肉:68.9元";
            %>
            <br><%=str%>
            <br> <b><i>消费总和:<%=getPriceSum(str)%></i> </b> <br>李四的菜单:
    
            <%
         str = "剁椒鱼头:62.9元,烤鸭:199元,红焖大虾:289.9元";
     %>
            <br><%=str%>
            <br> <b><i>消费总和:<%=getPriceSum(str)%></i> </b>
    
    
        </p>
    
    
    </body>
    </html>

    2.P39 实验2 日期和时间

    <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
    
    
    
    <%@ page import="java.time.LocalDate"%>
    <%@ page import="java.time.LocalTime"%>
    <%
        LocalDate date = LocalDate.now();
    LocalTime time = LocalTime.now();
    %>
    <h2>
        用户在<%=date.getYear()%>/<%=date.getMonthValue()%>/
        <%=date.getDayOfMonth()%><br>
        <%=time.getHour()%>:<%=time.getMinute()%>:<%=time.getSecond()%>访问了网页.
    </h2>
    <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
    
    
    <hTML>
    <body>
        <h1>
            显示访问网页的日期、时间<br>(服务器端的日期、时间)
        </h1>
        <%@include file="time.jsp"%>
    </body>
    </hTML>

     3.实验三 听英语

    <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
    
    <html>
    
    <body bgcolor=cyan>
        <br>英文课文(ENglish Text):
        <p style="font-family:宋体;font-size:18;color:black">
            <jsp:include page="english/english.txt" />
            <br>课文音频(English Audio):
            <jsp:include page="audio.jsp" /></p>
    
    </body>
    </html>
    
    
    <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
    
    
    <html>
    
    
    <body bgcolor=pink>
        <embed src="english/english.mp3" autostart=false>
        课文音频
        </embed>
    </body>
    </html>
  • 相关阅读:
    字体颜色和字体样式的演示
    消息的测试
    java泛型例子
    python画太阳花
    列出进程界面
    画蟒蛇
    同切圆的绘制
    IDEA 2019.3.1永久破解
    springMVC ——Controller配置方式
    SpringMVC——JSR303的数据校验Hibernate Validator方式实现
  • 原文地址:https://www.cnblogs.com/menfanbo/p/14549372.html
Copyright © 2020-2023  润新知