zoukankan      html  css  js  c++  java
  • JSP中声明变量、方法

    在JSP页面中声明局部变量,全局变量,方法等

    代码示例:

    <%@ page language="java" contentType="text/html; charset=UTF-8"
        pageEncoding="UTF-8"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Insert title here</title>
    </head>
    <body>
        <%
            int i = 0;
        %>
        <%!
        int j = 0, k = 1;
        public int add() {
            return j + k;
        }
        %>
        i++:<%=i++%><br> j++:<%=j++%><br> k++:<%=k++%><br>
        add()<%=add()%>
    </body>
    </html>

    注意:

    <%! %>用来声明全局变量和方法,<% %>用来声明局部变量。

  • 相关阅读:
    Java 高级文件处理
    drf10
    drf9
    drf8
    drf7
    drf6
    drf5
    drf4
    drf3
    drf2
  • 原文地址:https://www.cnblogs.com/YeHuan/p/10857702.html
Copyright © 2011-2022 走看看