meta標籤,meta
摘自w3cschool的圖:
這個標籤有一個必需屬性和一個可選屬性:
總結下mate標籤的作用:
1、指定當前頁面的編碼
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
相當於在 dopost() / doget() 方法中設定
request.setCharacterEncoding("utf-8");
response.setContentType("text/html;charset=utf-8");2、實現定時跳轉
<!-- 使用meta標籤實現重新導向 --><meta http-equiv="refresh" content="5; url=http://localhost/demo/login.jsp" >
content屬性:
一般定時跳轉都會結合js實現秒數的變化:
<%@ 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"><!-- 使用meta標籤實現重新導向 --><meta http-equiv="refresh" content="5; url=http://localhost/day2/login.jsp" ><title>Insert title here</title><script type="text/javascript"> //這個js實現了頁面顯示秒數的改變,具體的跳轉由meta標籤實現 var inner; window.onload = function(){ inner = window.setInterval("showTime()", 1000); } function showTime(){ var time = document.getElementById("time"); var timeValue = time.innerHTML; if(timeValue>0){ time.innerHTML -= 1; }else{ window.clearInterval(inner); } }</script></head><body> <span id="time">5</span>秒後跳轉到登入頁面,如未跳轉,請點擊<a href="${pageContext.request.contextPath }/login.jsp">此處</a></body></html>3、