栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

jsp自定义c:if标签

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

jsp自定义c:if标签

java代码:

package com.zx.tag;

import java.io.IOException;
import java.io.StringWriter;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.SimpleTagSupport;

public class IfTag extends SimpleTagSupport {
	//1.获取属性名为test的属性值
	
	private boolean test;

	public void setAbc(boolean test) {
		this.test = test;
	}

	@Override
	public void doTag() throws JspException, IOException {
		//2.判断属性值是否为true
		if(test) {
			//3.根据判断结果决定是否显示标签体的内容
			StringWriter sw = new StringWriter();
			this.getJspBody().invoke(sw);
			this.getJspContext().getOut().write(sw.toString());
		}
	}
}

tld代码:




    自定义标签
	zdytag
	1.0
	
	zy
	http://www.zhuoxun/jxb
	
		这个标签用来将标签体的内容小写改大写
    	if
    	com.zx.tag.IfTag
    	scriptless
    	
    	
    		条件判断
    		abc
    		
    		true
    		
    		true
    	
	

html代码:

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://www.zhuoxun/jxb" prefix="zy"%>




main


	<%
		request.setAttribute("address", "TianJin");
		String address = "TianJin";
		request.setAttribute("sex", "man");
	%>
	
	
	
	
	性别:
	


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/665666.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号