JSP指令与动作元素-include指令

include指令
语法:
<%@include file=“URL”%>

输出当前日期 date.jsp

<%@page import="java.text.SimpleDateFormat"%>
<%@ page language="java" import="java.util.*" contentType="text/html; charset=utf-8"
    %>
<%
	Date d = new Date();
	SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日");
	String a = sdf.format(d);
	out.println(a);
%>

测试include指令页面include_command.jsp

<%@ page language="java" contentType="text/html; charset=utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Insert title here</title>
</head>
<body>
	<h1>Include指令</h1>
	<hr>
	<%@include file="date.jsp" %>
</body>
</html>

在这里插入图片描述

发布了37 篇原创文章 · 获赞 1 · 访问量 402

猜你喜欢

转载自blog.csdn.net/qq_45444864/article/details/105725894