引入

  1. <%@ taglib prefix="sys" tagdir="/WEB-INF/tags/sys" %>

这里注意/WEB-INF/tags/sys这里是一个目录,目录下有很多tag文件如下,调用sys:xxx,就会在当前目录下找xxx.tag的文件,必须有对应xxx.tag的文件与之对应

  1. <%@ tag language="java" pageEncoding="UTF-8"%>
  2. <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
  3. <%@ taglib prefix="fns" uri="/WEB-INF/tlds/fns.tld" %>
  4. <%@ attribute name="typeCode" type="java.lang.String" required="true" description="字典code"%>
  5. <%@ attribute name="defaultValue" type="java.lang.String" description="默认选中"%>
  6. <%@ attribute name="style" type="java.lang.String" description="默认选中"%>
  7. <%@ attribute name="cls" type="java.lang.String" description="默认选中"%>
  8. <%@ attribute name="name" type="java.lang.String" description="默认选中"%>
  9. <select style="${style}" class="${cls}" name="${name}" id="${name}" >
  10. <option value="" >请选择... </option>
  11. <c:if test="${not empty typeCode}">
  12. <c:forEach items="${fns:getDictList(typeCode)}" var='dict'>
  13. <option value='${dict.VALUE}' ${defaultValue==dict.VALUE?'selected':''}>${dict.TEXT}</option>
  14. </c:forEach>
  15. </c:if>
  16. </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

  1. <%@ tag language="java" pageEncoding="UTF-8"%>
  2. <%@ include file="/WEB-INF/views/include/taglib.jsp"%>
  3. <%@ attribute name="id" type="java.lang.String" required="true" description="编号"%>
  4. <%@ attribute name="name" type="java.lang.String" required="true" description="隐藏域名称(ID)"%>
  5. <%@ attribute name="value" type="java.lang.String" required="true" description="隐藏域值(ID)"%>
  6. <%@ attribute name="labelName" type="java.lang.String" required="true" description="输入框名称(Name)"%>
  7. <%@ attribute name="labelValue" type="java.lang.String" required="true" description="输入框值(Name)"%>
  8. <%@ attribute name="title" type="java.lang.String" required="true" description="选择框标题"%>
  9. <%@ attribute name="url" type="java.lang.String" required="true" description="树结构数据地址"%>
  10. <%@ attribute name="checked" type="java.lang.Boolean" required="false" description="是否显示复选框,如果不需要返回父节点,请设置notAllowSelectParent为true"%>
  11. <%@ attribute name="extId" type="java.lang.String" required="false" description="排除掉的编号(不能选择的编号)"%>
  12. <%@ attribute name="isAll" type="java.lang.Boolean" required="false" description="是否列出全部数据,设置true则不进行数据权限过滤(目前仅对Office有效)"%>
  13. <%@ attribute name="notAllowSelectRoot" type="java.lang.Boolean" required="false" description="不允许选择根节点"%>
  14. <%@ attribute name="notAllowSelectParent" type="java.lang.Boolean" required="false" description="不允许选择父节点"%>
  15. <%@ attribute name="module" type="java.lang.String" required="false" description="过滤栏目模型(只显示指定模型,仅针对CMS的Category树)"%>
  16. <%@ attribute name="selectScopeModule" type="java.lang.Boolean" required="false" description="选择范围内的模型(控制不能选择公共模型,不能选择本栏目外的模型)(仅针对CMS的Category树)"%>
  17. <%@ attribute name="allowClear" type="java.lang.Boolean" required="false" description="是否允许清除"%>
  18. <%@ attribute name="allowInput" type="java.lang.Boolean" required="false" description="文本框可填写"%>
  19. <%@ attribute name="cssClass" type="java.lang.String" required="false" description="css样式"%>
  20. <%@ attribute name="cssStyle" type="java.lang.String" required="false" description="css样式"%>
  21. <%@ attribute name="smallBtn" type="java.lang.Boolean" required="false" description="缩小按钮显示"%>
  22. <%@ attribute name="hideBtn" type="java.lang.Boolean" required="false" description="是否显示按钮"%>
  23. <%@ attribute name="disabled" type="java.lang.String" required="false" description="是否限制选择,如果限制,设置为disabled"%>
  24. <%@ attribute name="dataMsgRequired" type="java.lang.String" required="false" description=""%>
  25. <div class="input-append">
  26. <input id="${id}Id" name="${name}" class="${cssClass}" type="hidden" value="${value}"/>
  27. <input id="${id}Name" name="${labelName}" ${allowInput?'':'readonly="readonly"'} type="text" value="${labelValue}" data-msg-required="${dataMsgRequired}"
  28. class="${cssClass}" style="${cssStyle}"/><a id="${id}Button" href="javascript:" class="btn ${disabled} ${hideBtn ? 'hide' : ''}" style="${smallBtn?'padding:4px 2px;':''}">&nbsp;<i class="icon-search"></i>&nbsp;</a>&nbsp;&nbsp;
  29. </div>
  30. <script type="text/javascript">
  31. $("#${id}Button, #${id}Name").click(function(){
  32. // 是否限制选择,如果限制,设置为disabled
  33. if ($("#${id}Button").hasClass("disabled")){
  34. return true;
  35. }
  36. // 正常打开
  37. top.$.jBox.open("iframe:${ctx}/tag/treeselect?url="+encodeURIComponent("${url}")+"&module=${module}&checked=${checked}&extId=${extId}&isAll=${isAll}", "选择${title}", 300, 420, {
  38. ajaxData:{selectIds: $("#${id}Id").val()},buttons:{"确定":"ok", ${allowClear?"\"清除\":\"clear\", ":""}"关闭":true}, submit:function(v, h, f){
  39. if (v=="ok"){
  40. var tree = h.find("iframe")[0].contentWindow.tree;//h.find("iframe").contents();
  41. var ids = [], names = [], nodes = [];
  42. if ("${checked}" == "true"){
  43. nodes = tree.getCheckedNodes(true);
  44. }else{
  45. nodes = tree.getSelectedNodes();
  46. }
  47. for(var i=0; i<nodes.length; i++) {//<c:if test="${checked && notAllowSelectParent}">
  48. if (nodes[i].isParent){
  49. continue; // 如果为复选框选择,则过滤掉父节点
  50. }//</c:if><c:if test="${notAllowSelectRoot}">
  51. if (nodes[i].level == 0){
  52. top.$.jBox.tip("不能选择根节点("+nodes[i].name+")请重新选择。");
  53. return false;
  54. }//</c:if><c:if test="${notAllowSelectParent}">
  55. if (nodes[i].isParent){
  56. top.$.jBox.tip("不能选择父节点("+nodes[i].name+")请重新选择。");
  57. return false;
  58. }//</c:if><c:if test="${not empty module && selectScopeModule}">
  59. if (nodes[i].module == ""){
  60. top.$.jBox.tip("不能选择公共模型("+nodes[i].name+")请重新选择。");
  61. return false;
  62. }else if (nodes[i].module != "${module}"){
  63. top.$.jBox.tip("不能选择当前栏目以外的栏目模型,请重新选择。");
  64. return false;
  65. }//</c:if>
  66. ids.push(nodes[i].id);
  67. names.push(nodes[i].name);//<c:if test="${!checked}">
  68. break; // 如果为非复选框选择,则返回第一个选择 </c:if>
  69. }
  70. $("#${id}Id").val(ids.join(",").replace(/u_/ig,""));
  71. $("#${id}Name").val(names.join(","));
  72. }//<c:if test="${allowClear}">
  73. else if (v=="clear"){
  74. $("#${id}Id").val("");
  75. $("#${id}Name").val("");
  76. }//</c:if>
  77. if(typeof ${id}TreeselectCallBack == 'function'){
  78. ${id}TreeselectCallBack(v, h, f);
  79. }
  80. }, loaded:function(h){
  81. $(".jbox-content", top.document).css("overflow-y","hidden");
  82. }
  83. });
  84. });
  85. </script>


jsp tag 直接文件实现的更多相关文章

  1. JSP TAG

    Jsp tag 能够灵活的将公共JSP代码模块化,类似<jsp:include page="./include.jsp"></jsp:include>等等. ...

  2. Servlet和JSP之标签文件学习

    在上一篇文章中介绍了自定义标签的用法,接下来介绍标签文件的用法啦. tag file指令 tag file简介 用tag file的方式,无需编写标签处理类和标签库描述文件,也可以自定义标签.tag ...

  3. Liferay JSP Tag Libraries介绍

    Liferay自带了很多标签库,这极大地提高了开发Liferay项目的效率. 下面让我们一起来探索吧. 什么是标签库? 什么是JSP标签? 什么是JSTL? 标签库由下面这几部分组成: Tag Lib ...

  4. jsp读取properties文件

    jsp读取properties文件 jsp中读取properties文件,并把值设到js变量中: mpi.properties文件内容: MerchantID=00000820 CustomerEMa ...

  5. Eclipse中jsp、js文件编辑时,卡死现象解决汇总

    使用Eclipse编辑jsp.js文件时,经常出现卡死现象,在网上百度了N次,经过N次优化调整后,卡死现象逐步好转,具体那个方法起到作用,不太好讲.将所有用过的方法罗列如下: 1.取消验证 windo ...

  6. Java使用JSP Tag Files & JSP EL Functions打造你自己的页面模板

    1. 简单说明:在JSP 2.0后, 你不再需要大刀阔斧地定义一堆TagSupport或BodyTagSupport, 使用JSP Tag Files技术可以实现功能强大的页面模板技术. 在这里抛砖引 ...

  7. Eclipse编辑jsp、js文件时,经常出现卡死现象解决汇总

    使用Eclipse编辑jsp.js文件时,经常出现卡死现象,在网上百度了N次,经过N次优化调整后,卡死现象逐步好转,具体那个方法起到作用,不太好讲.将所有用过的方法罗列如下: 1.取消验证 windo ...

  8. eclipse中web项目部署以后jsp的java文件找不到问题(Tomcat配置serverlocations)

    我的开发环境:eclipse kepler (4.3)+tomcat7.0.42. 在我想看eclipse中web项目jsp文件被tomcat转换成java以后的java源文件的位置,发现正常情况下的 ...

  9. JSP生成word文件

    1.jsp生成word文件,直接改动jsp格式: <%@ page contentType="application/vnd.ms-word;charset=GB2312"% ...

随机推荐

  1. 17、percona-toolkit

    pt-ioprofile工具:1.percona-toolkit(在http://www.percona.com下载)2.安装该工具依赖的perl组件yum install perl-IO-Socke ...

  2. LINUX之内网渗透提权

    在渗透测试过程中,经常遇到如下情形,内部网络主机通过路由器或者安全设备做了访问控制,无法通过互联网直接访问本地开放的服务,Windows方 面,国内通常选择Lcx.exe来进行端口转发,在应用方面大多 ...

  3. dedecms会员注册注入漏洞

    一.首先访问“/data/admin/ver.txt”页面获取系统最后升级时间,(判断是否是dede的cms 以及看看是否和这个漏洞相对应)二.然后访问“/member/ajax_membergrou ...

  4. Enyim Memached 客户端 执行GET 总是返回NULL

    排查: 1. ping 远程Linux 服务器 正常 2.11211 端口正常 3. ps aux | grep memcached 显示正常 4. 使用另外一个客户端 memcachedClient ...

  5. mysql索引处理

    1.索引作用在索引列上,除了上面提到的有序查找之外,数据库利用各种各样的快速定位技术,能够大大提高查询效率.特别是当数据量非常大,查询涉及多个表时,使用索引往往能使查询速度加快成千上万倍.例如,有3个 ...

  6. java实现快速排序算法

    1.算法概念. 快速排序(Quicksort)是对冒泡排序的一种改进.由C. A. R. Hoare在1962年提出.2.算法思想. 通过一趟排序将要排序的数据分割成独立的两部分,其中一部分的所有数据 ...

  7. 使用JTextArea示例

    相对于JLabel显示提示文字,JTextArea有一个先天优势:文字可以拷贝出来.经过下面设置它也能在外观上和JLabel一致. 代码如下: JTextArea txtArea=new JTextA ...

  8. .NET Framwork 之 托管代码的执行过程

    源代码代码第一次编译形成IL中间语言的托管代码,在运行时被Class Loader装载后进行JIT第二次编译形成托管的本地代码.在执行过程中,它会不断地检查当前我们执行的代码的安全性和规范性. Cla ...

  9. Unity3.5 GameCenter基础教程(转载)

    原地址: http://forum.unity3d.com/threads/116901-Game-Center-Support/page3 using UnityEngine; using Unit ...

  10. 算法笔记_162:算法提高 复数归一化(Java)

    目录 1 问题描述 2 解决方案   1 问题描述 编写函数Normalize,将复数归一化,即若复数为a+bi,归一化结果为a/sqrt(a*a+b*b) + i*b/sqrt(a*a+b*b) . ...