jsp tag 直接文件实现
引入
<%@ taglib prefix="sys" tagdir="/WEB-INF/tags/sys" %>
这里注意/WEB-INF/tags/sys这里是一个目录,目录下有很多tag文件如下,调用sys:xxx,就会在当前目录下找xxx.tag的文件,必须有对应xxx.tag的文件与之对应
<%@ tag language="java" pageEncoding="UTF-8"%><%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%><%@ taglib prefix="fns" uri="/WEB-INF/tlds/fns.tld" %><%@ attribute name="typeCode" type="java.lang.String" required="true" description="字典code"%><%@ attribute name="defaultValue" type="java.lang.String" description="默认选中"%><%@ attribute name="style" type="java.lang.String" description="默认选中"%><%@ attribute name="cls" type="java.lang.String" description="默认选中"%><%@ attribute name="name" type="java.lang.String" description="默认选中"%><select style="${style}" class="${cls}" name="${name}" id="${name}" ><option value="" >请选择... </option><c:if test="${not empty typeCode}"><c:forEach items="${fns:getDictList(typeCode)}" var='dict'><option value='${dict.VALUE}' ${defaultValue==dict.VALUE?'selected':''}>${dict.TEXT}</option></c:forEach></c:if></select>attribute的属性介绍如下:
1. name :这个attribute的名称.
2. required : true/false, 是否必须的.
3. rtexprvalue : true/false, 这个attribute可否使用EL表达式, 否则为纯文本.
4. type : 设定这个attribute的类型, jsp容器会把结果自动转换成这个类.
如此,jsp名就是标签名,例如这个jsp叫 select.jsp,那么它的用法就是
<sys:select cls="formselect" name="MODULE_TYPE" typeCode="HOME_MODULE_TYPE" defaultValue="${record.MODULE_TYPE }" />
附上一个实际例子
treeselect.tag
<%@ tag language="java" pageEncoding="UTF-8"%><%@ include file="/WEB-INF/views/include/taglib.jsp"%><%@ attribute name="id" type="java.lang.String" required="true" description="编号"%><%@ attribute name="name" type="java.lang.String" required="true" description="隐藏域名称(ID)"%><%@ attribute name="value" type="java.lang.String" required="true" description="隐藏域值(ID)"%><%@ attribute name="labelName" type="java.lang.String" required="true" description="输入框名称(Name)"%><%@ attribute name="labelValue" type="java.lang.String" required="true" description="输入框值(Name)"%><%@ attribute name="title" type="java.lang.String" required="true" description="选择框标题"%><%@ attribute name="url" type="java.lang.String" required="true" description="树结构数据地址"%><%@ attribute name="checked" type="java.lang.Boolean" required="false" description="是否显示复选框,如果不需要返回父节点,请设置notAllowSelectParent为true"%><%@ attribute name="extId" type="java.lang.String" required="false" description="排除掉的编号(不能选择的编号)"%><%@ attribute name="isAll" type="java.lang.Boolean" required="false" description="是否列出全部数据,设置true则不进行数据权限过滤(目前仅对Office有效)"%><%@ attribute name="notAllowSelectRoot" type="java.lang.Boolean" required="false" description="不允许选择根节点"%><%@ attribute name="notAllowSelectParent" type="java.lang.Boolean" required="false" description="不允许选择父节点"%><%@ attribute name="module" type="java.lang.String" required="false" description="过滤栏目模型(只显示指定模型,仅针对CMS的Category树)"%><%@ attribute name="selectScopeModule" type="java.lang.Boolean" required="false" description="选择范围内的模型(控制不能选择公共模型,不能选择本栏目外的模型)(仅针对CMS的Category树)"%><%@ attribute name="allowClear" type="java.lang.Boolean" required="false" description="是否允许清除"%><%@ attribute name="allowInput" type="java.lang.Boolean" required="false" description="文本框可填写"%><%@ attribute name="cssClass" type="java.lang.String" required="false" description="css样式"%><%@ attribute name="cssStyle" type="java.lang.String" required="false" description="css样式"%><%@ attribute name="smallBtn" type="java.lang.Boolean" required="false" description="缩小按钮显示"%><%@ attribute name="hideBtn" type="java.lang.Boolean" required="false" description="是否显示按钮"%><%@ attribute name="disabled" type="java.lang.String" required="false" description="是否限制选择,如果限制,设置为disabled"%><%@ attribute name="dataMsgRequired" type="java.lang.String" required="false" description=""%><div class="input-append"><input id="${id}Id" name="${name}" class="${cssClass}" type="hidden" value="${value}"/><input id="${id}Name" name="${labelName}" ${allowInput?'':'readonly="readonly"'} type="text" value="${labelValue}" data-msg-required="${dataMsgRequired}"class="${cssClass}" style="${cssStyle}"/><a id="${id}Button" href="javascript:" class="btn ${disabled} ${hideBtn ? 'hide' : ''}" style="${smallBtn?'padding:4px 2px;':''}"> <i class="icon-search"></i> </a> </div><script type="text/javascript">$("#${id}Button, #${id}Name").click(function(){// 是否限制选择,如果限制,设置为disabledif ($("#${id}Button").hasClass("disabled")){return true;}// 正常打开top.$.jBox.open("iframe:${ctx}/tag/treeselect?url="+encodeURIComponent("${url}")+"&module=${module}&checked=${checked}&extId=${extId}&isAll=${isAll}", "选择${title}", 300, 420, {ajaxData:{selectIds: $("#${id}Id").val()},buttons:{"确定":"ok", ${allowClear?"\"清除\":\"clear\", ":""}"关闭":true}, submit:function(v, h, f){if (v=="ok"){var tree = h.find("iframe")[0].contentWindow.tree;//h.find("iframe").contents();var ids = [], names = [], nodes = [];if ("${checked}" == "true"){nodes = tree.getCheckedNodes(true);}else{nodes = tree.getSelectedNodes();}for(var i=0; i<nodes.length; i++) {//<c:if test="${checked && notAllowSelectParent}">if (nodes[i].isParent){continue; // 如果为复选框选择,则过滤掉父节点}//</c:if><c:if test="${notAllowSelectRoot}">if (nodes[i].level == 0){top.$.jBox.tip("不能选择根节点("+nodes[i].name+")请重新选择。");return false;}//</c:if><c:if test="${notAllowSelectParent}">if (nodes[i].isParent){top.$.jBox.tip("不能选择父节点("+nodes[i].name+")请重新选择。");return false;}//</c:if><c:if test="${not empty module && selectScopeModule}">if (nodes[i].module == ""){top.$.jBox.tip("不能选择公共模型("+nodes[i].name+")请重新选择。");return false;}else if (nodes[i].module != "${module}"){top.$.jBox.tip("不能选择当前栏目以外的栏目模型,请重新选择。");return false;}//</c:if>ids.push(nodes[i].id);names.push(nodes[i].name);//<c:if test="${!checked}">break; // 如果为非复选框选择,则返回第一个选择 </c:if>}$("#${id}Id").val(ids.join(",").replace(/u_/ig,""));$("#${id}Name").val(names.join(","));}//<c:if test="${allowClear}">else if (v=="clear"){$("#${id}Id").val("");$("#${id}Name").val("");}//</c:if>if(typeof ${id}TreeselectCallBack == 'function'){${id}TreeselectCallBack(v, h, f);}}, loaded:function(h){$(".jbox-content", top.document).css("overflow-y","hidden");}});});</script>
jsp tag 直接文件实现的更多相关文章
- JSP TAG
Jsp tag 能够灵活的将公共JSP代码模块化,类似<jsp:include page="./include.jsp"></jsp:include>等等. ...
- Servlet和JSP之标签文件学习
在上一篇文章中介绍了自定义标签的用法,接下来介绍标签文件的用法啦. tag file指令 tag file简介 用tag file的方式,无需编写标签处理类和标签库描述文件,也可以自定义标签.tag ...
- Liferay JSP Tag Libraries介绍
Liferay自带了很多标签库,这极大地提高了开发Liferay项目的效率. 下面让我们一起来探索吧. 什么是标签库? 什么是JSP标签? 什么是JSTL? 标签库由下面这几部分组成: Tag Lib ...
- jsp读取properties文件
jsp读取properties文件 jsp中读取properties文件,并把值设到js变量中: mpi.properties文件内容: MerchantID=00000820 CustomerEMa ...
- Eclipse中jsp、js文件编辑时,卡死现象解决汇总
使用Eclipse编辑jsp.js文件时,经常出现卡死现象,在网上百度了N次,经过N次优化调整后,卡死现象逐步好转,具体那个方法起到作用,不太好讲.将所有用过的方法罗列如下: 1.取消验证 windo ...
- Java使用JSP Tag Files & JSP EL Functions打造你自己的页面模板
1. 简单说明:在JSP 2.0后, 你不再需要大刀阔斧地定义一堆TagSupport或BodyTagSupport, 使用JSP Tag Files技术可以实现功能强大的页面模板技术. 在这里抛砖引 ...
- Eclipse编辑jsp、js文件时,经常出现卡死现象解决汇总
使用Eclipse编辑jsp.js文件时,经常出现卡死现象,在网上百度了N次,经过N次优化调整后,卡死现象逐步好转,具体那个方法起到作用,不太好讲.将所有用过的方法罗列如下: 1.取消验证 windo ...
- eclipse中web项目部署以后jsp的java文件找不到问题(Tomcat配置serverlocations)
我的开发环境:eclipse kepler (4.3)+tomcat7.0.42. 在我想看eclipse中web项目jsp文件被tomcat转换成java以后的java源文件的位置,发现正常情况下的 ...
- JSP生成word文件
1.jsp生成word文件,直接改动jsp格式: <%@ page contentType="application/vnd.ms-word;charset=GB2312"% ...
随机推荐
- C#动态调用webservice方法
摘 自: http://www.hao5191.cn/a/chengxukaifa/c_/20130109/115819.html using System; using System.Collect ...
- 解决:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.2:compile
在项目构建的时候遇到了这样的问题:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.2:compile(d ...
- 如何在 Ubuntu 上搭建网桥
导读作为一个 Ubuntu 16.04 LTS 的初学者.如何在 Ubuntu 14.04 和 16.04 的主机上搭建网桥呢?顾名思义,网桥的作用是通过物理接口连接内部和外部网络.对于虚拟端口或者 ...
- HTML学习笔记(五)
1. Javascript是一种脚本语言,它的作用是提供用户交互.动态更改内容.数据验证. 2. 我们使用script标签将javascript的语句嵌入到html文档中. 3 ...
- VLC播放RTSP视频延迟问题
VLC播放RTSP视频延迟问题 配置 VLC 以播放 RTSP/RTP 流 实测发现RTP都不如TCP快? vlc播放rtp封装的h.264延时很大是什么原因? 开启打印: VLC的工具->消息 ...
- 怎样将游戏从Unity导到iOS设备上
当我开始开发自己的iOS游戏时,我会考虑的第一件事便是如何将其导出到设备中,如此有效地测试我的游戏.最初,该过程看似很长且复杂,我所遇到的主要问题是,尽管存在许多资源,但是它们并非完全来自同样的地方, ...
- EditText输入为空button不可点击搜索
一丶任务详情 二丶改动后演示效果 三丶改动过程 分析:非常明显这里是须要监听EditText,推断输入字符串长度是否不为0来改变Button样式 首先的屡清楚代码逻辑在适当的位子加监听推断是最好的处理 ...
- java 学习总结
1 cobertura-maven-plugin maven的测试覆盖率插件集成cobertura-maven-plugin2 intelli J 配置VM参数 3 配置显示行号 mvn clean ...
- 【FinancialKnowledge】拨备
一句话: 银行拨备就是银行贷款损失减值准备的俗称,其相当于为承担风险和损失的金融资产计提的准备金 通俗易懂的解释见:https://wallstreetcn.com/articles/3307725
- 【微信小程序】退款功能教程(含申请退款和退款回调)
1.一定要区分小程序和公众号的退款,唯一的区别就是 appid不一样,其他的都是一样的. 不废话,直接写代码了啊. 放大招!!! 然后,需要注意的:最好是把证书放在下面的php的同级或者下级. 证书的 ...