EL overview of jsp

EL overview of jsp

##EL expression overview

  • What is an EL expression?
    EL (Express Lanuage) expressions can be embedded inside jsp pages

  • What is the meaning of EL expressions? It
    is to replace the writing of output scripts in jsp pages and reduce the writing of jsp scripts

  • How to write EL expression?

 ${EL表达式内容}
  • The role of EL expression:
    • Find the specified data from the domain object.
    • Built-in object usage
    • Execution operator

jsp page code:

<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<html>
  <head>
    <title>$Title$</title>
  </head>
  <body>

  <h1>我是jsp</h1>
  <!-- 方式1: 编译后代码存放在Service方法中 -->
  <%
    int a = 10;
    System.out.println(a);
  %>
  <!-- (3)方式2:这里的代码会被编译到成员位置 -->
  <%!
    String username;
    public void myMethod(){
      System.out.println("myMethod");
    }
  %>
  <!-- (4)方式3:页面输出内容 -->
  <%= "你想打印啥"%>

  </body>
</html>

running result:
Insert picture description here

Guess you like

Origin blog.csdn.net/qq_37924905/article/details/108594783