JSP脚本及指令


 

<%@ page import="java.util.Date" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page pageEncoding="UTF-8" buffer="16kb" %>
<%-- 使用taglib 指令设置引入自定义标签信息 --%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

  
    $Title$
  
  
  <%@ include file="view/top.jsp" %>
  <%-- 声明变量定义方法 --%>
  <%!
    String mess = "";//
    void sayHello(String name,String sex){
      if (sex.equals("男"))
        mess = "你好!"+name+" 先生";
      else
        mess = "你好!"+name+" 女士";
    }
  %>
  <%
    sayHello("King","男");
    Date dat = new Date();
    SimpleDateFormat sim = new SimpleDateFormat();
  %>
  <%=mess%>

  if test="${17 >=18}">
    

您是成年人

if> if test="${17 < 18}">

你是未成年人

if>
<%--
  Created by IntelliJ IDEA.
  User: zengy
  Date: 2022/1/31
  Time: 21:00
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>


    pages


    

<?xml version="1.0" encoding="UTF-8"?>

         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
         version="4.0">
    
        hello.jsp