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" %> <html> <head> <title>$Title$</title> </head> <body> <%@ 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%> <c:if test="${17 >=18}"> <h2>您是成年人</h2> </c:if> <c:if test="${17 < 18}"> <h2>你是未成年人</h2> </c:if> </body> </html>
<%-- 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" %> <html> <head> <title>pages</title> </head> <body> <img src="imgs/68670770_p0.jpg"> </body> </html>
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" 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"> <welcome-file-list> <welcome-file>hello.jsp</welcome-file> </welcome-file-list> </web-app>