博客
关于我
JSP的包含指令实战
阅读量:180 次
发布时间:2019-02-28

本文共 635 字,大约阅读时间需要 2 分钟。

JSP 包含指令实战指南

一、静态包含

静态包含采用 <%@include file="要包含的文件"%> 格式,特点是包含操作先于页面编译。这种方式适用于静态页面资源的加载,页面开发完成后即可完成资源整合。

二、动态包含

动态包含采用 <jsp:include page="要包含的文件"></jsp:include> 格式,包含操作会在页面编译后进行。这种方式适用于动态资源加载,支持参数传递和条件判断。

三、动态包含的实战应用

1. testInclude.jsp 代码

<%@ page pageEncoding="UTF-8" contentType="text/html" %>JSP 包含指令的使用
<% String msg = "WORLD" ; %>

2. include_param.jsp

<%@ page pageEncoding="UTF-8" contentType="text/html" %>JSP 包含指令

我是有参数的包含

<% request.getParameter("var1")%>
<% request.getParameter("var2")%>

3. 运行结果

通过运行 testInclude.jsp,页面会分别显示以下内容:

  • "HELLO"
  • "WORLD"

这种方式可以有效地实现页面资源的动态加载和参数传递,适用于灵活的页面组合需求。

转载地址:http://yzwn.baihongyu.com/

你可能感兴趣的文章
python ==》 字典
查看>>
python anaconda 安装使用
查看>>
python and或or 当参数传递的时候的用法
查看>>
Python append() 与列表上的 + 运算符,为什么这些会给出不同的结果?
查看>>
Python APP自动化测试工具adb与Monkey使用详解
查看>>
Python APP自动化测试框架Appium详解
查看>>
Python APP自动化测试框架开发实战
查看>>
python argparse模块
查看>>
Python asyncio库的学习和使用
查看>>
Python AttributeError:“dict“对象没有属性“append“
查看>>
Python base64和hashlib模块
查看>>
python basic programs
查看>>
python bert_gen.py 报错Unable to load weights from pytorch checkpoint file for......
查看>>
python binascii.Error: Incorrect padding
查看>>
Python bool() 函数能否为无效参数引发异常?
查看>>
Python C 程序子进程在“for line in iter“处挂起
查看>>
Python Celery:自动化测试平台定时任务必备的三方库
查看>>
python check_output 失败,退出状态为 1,但 Popen 适用于相同的命令
查看>>
Python CONNECT 4 CHECK WIN函数
查看>>
python cos,Python cos(90)和cos(270)不是0
查看>>