meta標籤,meta

來源:互聯網
上載者:User

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屬性:

  • 前面是時間值,單位秒;
  • 後面是url路徑。

一般定時跳轉都會結合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、

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.