分享

Java开发总结下mate标签的作用 优就业

 科技新讯 2017-03-27
每日头条
5天前
2017-03-21
[ 文章导读 ] 总结下mate标签的作用:1、指定当前页面的编码<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">相当于在 dopost() / doget() 方法中设置request.setCharacterEncoding("utf-8");response.setContentType("text/html;charset=u ...

总结下mate标签的作用:

Java开发总结下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./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>

更多Java开发知识尽在优就业IT培训:http://www./

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多