jsp用java运行当前时间 | 您所在的位置:网站首页 › jsp输出当前系统时间 › jsp用java运行当前时间 |
JSP显示当前系统时间的四种方式: 第一种java内置时间类实例化对象: String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> My JSP 'time4.jsp' starting pagejava.text.SimpleDateFormat simpleDateFormat = new java.text.SimpleDateFormat( "yyyy-MM-dd HH:mm:ss"); java.util.Date currentTime = new java.util.Date(); String time = simpleDateFormat.format(currentTime).toString(); out.println("当前时间为:"+time); %> 第二种方式使用JSP内置USEBEAN实例化时间类: String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> 显示系统时间 |
CopyRight 2018-2019 实验室设备网 版权所有 |