间的js代码都不执行 代码如下","upDate":"2022-01-18T00:00:00+08:00"}
Leoposn 2022-01-10 22:23 采纳率: 100%
浏览 54
已结题

jsp新手写了书上的代码 发现<script></script>间的js代码都不执行 代码如下


<%@ page contentType= "text/html" %>
<%@ page pageEncoding = "utf-8" %>
<%@ page import="java.time.LocalTime" %>
<%!    public int continueSum(int start,int end){
        int sum=0;
        for(int i=start;i<=end;i++){
            sum+=i;
        }
            return sum;
    }
%>
<HTML><body bgcolor=cyan>
<script>
  var userTime= new Date();
  var hour = userTime.getHour();
  var minute = userTime.getMinute();
  var second = userTime.getMinute();
  var millisecond = userTime.getMillisecond();
  document.write("<h2>浏览器时间:"+hour+":"+minute+":"+second+":"+millisecond+"<br></h2>);
</script>
<img src = "image/time.jpg" width=180 height=120/>
<p style ="font-family:黑体;font-size:36;color:red">
<%
    LocalTime timeServer = LocalTime.now();
    int hour = timeServer.getHour();
    int minute = timeServer.getMinute();
      int second = timeServer.getMinute();
    int nano = timeServer.getNano();
      int millisecond = nano/1000000;
    out.print("服务器时间:<br>"+hour+":"+minute+":"+second+":"+millisecond);
    int start=1;
    int end = 100;
    int sum = continueSum(start,end);
%>
</p>
<p style ="font-family:宋体;font-size:33;color:green">
  从
  <%= start %>
  至
  <%= end%>
  的<br>连续和是:
  <%= sum %>
</p>
<script>
document.write("<h2>服务器时间:"+<%= hour %>+":"+<%= minute %>+":"+<%= second %>+":"+<%= millisecond %>+"</h2>);
</script>
</body></HTML>
  • 写回答

2条回答 默认 最新

  • 关注

    你题目的解答代码如下:

    <!doctype html>
    <html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
        <title> 页面名称 </title>
    <style type="text/css">
    #div {
    
    }
    </style>
    </head>
    <body>
     
    <%@ page contentType= "text/html" %>
    <%@ page pageEncoding = "utf-8" %>
    <%@ page import="java.time.LocalTime" %>
    <%!    public int continueSum(int start,int end){
            int sum=0;
            for(int i=start;i<=end;i++){
                sum+=i;
            }
                return sum;
        }
    %>
    <HTML><body bgcolor=cyan>
    <script>
      var userTime= new Date();
      var hour = userTime.getHours();
      var minute = userTime.getMinutes();
      var second = userTime.getMinutes()
      var millisecond = userTime.getMilliseconds();
      document.write("<h2>浏览器时间:"+hour+":"+minute+":"+second+":"+millisecond+"<br></h2>");
    </script>
    <img src = "image/time.jpg" width=180 height=120/>
    <p style ="font-family:黑体;font-size:36;color:red">
    <%
        LocalTime timeServer = LocalTime.now();
        int hour = timeServer.getHour();
        int minute = timeServer.getMinute();
          int second = timeServer.getMinute();
        int nano = timeServer.getNano();
          int millisecond = nano/1000000;
        out.print("服务器时间:<br>"+hour+":"+minute+":"+second+":"+millisecond);
        int start=1;
        int end = 100;
        int sum = continueSum(start,end);
    %>
    </p>
    <p style ="font-family:宋体;font-size:33;color:green"><%= start %><%= end%><br>连续和是:
      <%= sum %>
    </p>
    <script>
    document.write("<h2>服务器时间:"+<%= hour %>+":"+<%= minute %>+":"+<%= second %>+":"+<%= millisecond %>+"</h2>");
    </script>
    </body></HTML>
    
    <script type="text/javascript">
    
    </script>
    </body>
    </html>
    

    如有帮助,请点击我的回答下方的【采纳该答案】按钮帮忙采纳下,谢谢!

    img

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 1月18日
  • 已采纳回答 1月10日
  • 创建了问题 1月10日

悬赏问题

  • ¥60 Qcustomplot绘制实时动态曲线
  • ¥20 运用matlab画x-y图
  • ¥15 用idea运行项目,运行tomcat报错:断言失败
  • ¥15 Sqlserver查询链接服务器数据问题
  • ¥15 Bibtex4Word 引用中文文献
  • ¥20 用opencv c/c++ 转换成灰度图,然后做一下直方图均衡,输出mp4文件
  • ¥20 matlab中的双层数值积分
  • ¥50 服务器打印水晶报表问题
  • ¥30 gradle环境下javafx项目如何使用druid连接池
  • ¥15 服务器打印水晶报表问题