jsp 重定向、定时刷新

重定向

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
    <select name="select" id="">
        <option value="">====请选择====</option>
        <option value="1">中国系统分析员</option>
        <option value="2">系统测试员</option>
    </select>
    <%
        //页面重定向程序代码
        String url;
        // url=request.getParameter("goaddress");
        url="array.jsp";
        if(url != null){
        response.sendRedirect(url);
    }
    %>
</body>
</html>

定时刷新

<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.util.*"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>定时刷新页面</title>
</head>
<body>
    <%
        //设置刷新页面的时间,每隔3秒刷新一次
        response.setIntHeader("refresh",3);
    %>
    <p>当前系统的时间是</p>

    <%
    Date date=new Date();
    SimpleDateFormat sdf=new SimpleDateFormat("yyyy'年'MM'月'dd'日'hh'时'mm'分'ss'秒'");
    out.println(date);
    %>
    <p>
    <%
    out.println(sdf.format(date));
    %>
    </p>
</body>
</html>

猜你喜欢

转载自blog.csdn.net/weiyumeizi/article/details/72731444
今日推荐