JSP from shallow to deep (7) — JSP directives
In the previous tutorial, we have used java util. Date。 Some people will ask: why not just use import Java util.* And? In fact, the import statement can also be used in JSPS, but its syntax is somewhat different from that of ordinary Java. An example is given below:
<%@ page import="java.util.*" %>
<%
System. out. println( "Evaluating date Now" );
Date date = new Date();
%>
Hello! The time is Now <%= date %>
In the first line of the above code, we call a "directive". The JSP "directive" starts with the <% @ character. This is a "page directive". This "page directive" can contain all the imported items. If you want to introduce more than one item, you can use commas (,) to separate items, such as:
<%@ page import="java.util.*,java.text.*" %>
There can be multiple JSP directives in "page directives". Besides "page directive", other useful directives are include and taglib. We will discuss taglib in detail in a later tutorial. Only include directive is discussed here.