jsp内置对象application&富文本编辑器&文件上传

application

介绍

介绍:application意思是应用程序,是JSP内置对象,类似于“全局变量”,应用于实现用户之间的数据共享

常用方法

返回类型 方法 说明
void setAttribute(String key, Object value) 以key/value的形式保存对象值
Object getAttribute(String key) 通过key获取对象值
String getRealPath(String path) 返回相对路径的真实路径

案例:实现访问人数统计

<%@ 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>
	<%
		/*  Integer 是 int 的封装类,
			int 的默认I值是0
			Integer 的默认值是null
		*/
		Integer count = 0;
		Integer c = (Integer)application.getAttribute("count");
		if(c != null){
   //说明有数据
			count = c;
		}
		count ++;//把当前的用户加进去
		// 然后再把更改后的用户数量保存到application的作用域
		application.setAttribute("count", count);
	%>
	<h1>
		你是第<%=application.getAttri
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值