您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

jsp中变量及方法的声明与使用说明

2025/6/14 5:55:25发布22次查看
这篇文章主要介绍了jsp中变量及方法的声明与使用,以实例形式分析了jsp中变量的声明,赋值及方法的定义与使用技巧,需要的朋友可以参考下
本文实例讲述了jsp中变量及方法的声明与使用。分享给大家供大家参考,具体如下:
<%@ page language="java" import="java.util.*" contenttype="text/html;charset=gbk"%> <% string path = request.getcontextpath(); string basepath = request.getscheme()+"://"+request.getservername()+":"+request.getserverport()+path+"/"; %> <!doctype html public "-//w3c//dtd html 4.01 transitional//en"> <html> <head> <base href="<%=basepath%>"> <title>jsp 中声明的使用</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="this is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> </head> <body> <h1 align="center">演示声明的使用</h1> <%--声明变量--%> <%!long i = 1,j=1; %> <%!string name="陈宁"; %> <%!string name2="官林辉"; %> <%--声明方法--%> <%!public string sayhello(string who) { return "您好:"+who; } %> <p align="center"> <% out.println(sayhello(name)); out.println("<br>"); out.println("您是第"+i+"个访问本网站的用户!"); i++; %> <% date time = new date(); out.write(time.tolocalestring()); %> </p> <p align="center"> <%=sayhello(name2)%> <br> 您是第<%= j%>个访问本网站的用户! <%j++;%> </p> </body> </html>
以上就是jsp中变量及方法的声明与使用说明的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product