jstl自定义标签
来源:互联网 发布:《linux就该这么学 编辑:程序博客网 时间:2024/06/03 20:48
1、引入jstl.jar
<!-- JSTL标签类 --><dependency><groupId>jstl</groupId><artifactId>jstl</artifactId><version>1.2</version></dependency>
2、自定义标签处理类
package com.loan.security.web.taglib;import java.util.List;import org.springframework.web.bind.annotation.ResponseBody;import com.loan.security.entity.Dictionary;import com.loan.security.service.DictionaryService;import com.loan.security.spring.SpringUtils;public class DictionaryFunction {private static DictionaryService dictionaryService;public static @ResponseBody List<Dictionary> getDictionarysByCode(String code) {Dictionary dic=new Dictionary();dic.setCode(code);return getDictionaryService().find(dic);}public static DictionaryService getDictionaryService() {if(dictionaryService == null) {dictionaryService = SpringUtils.getBean(DictionaryService.class);}return dictionaryService;}}
3、标签库描述文件(TLD)
<?xml version="1.0" encoding="UTF-8"?><taglib xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd" version="2.0"> <description>functions</description> <tlib-version>3.0</tlib-version> <short-name>fn</short-name> <function> <description>根据code查询字典列表</description> <name>getDictionarysByCode</name> <function-class>com.loan.security.web.taglib.DictionaryFunction</function-class> <function-signature>java.util.List getDictionarysByCode(java.lang.String)</function-signature> </function></taglib>4、jsp中引入并使用自定义标签
<%@ page contentType="text/html;charset=UTF-8" language="java"%><%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%><%@ taglib prefix="dictionary"uri="/WEB-INF/tld/dictionary_function.tld"%><%@taglib prefix="shiro" uri="http://shiro.apache.org/tags"%><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><meta http-equiv="X-UA-Compatible" content="IE=edge" /><title></title><script type="text/javascript"src="${pageContext.request.contextPath}/static/common/easy-ui/js/jquery.min.js"></script></head><body style="margin: 0px; padding: 0px; height: 100%; font-family: 微软雅黑;"><div style="padding: 10px;"><label style="width: 15%">类型:</label> <select style="width: 30%" name="type" class="easyui-combobox" required="true"><c:forEach items="${dictionary:getDictionarysByCode('0003')}" var="dic"><option value="${dic.name}">${dic.name}</option></c:forEach></select> </div></body></html>
阅读全文
0 0
- JSTL自定义标签问题
- 自定义jstl标签库
- JSTL - 自定义标签
- JSTL自定义标签
- jstl自定义标签
- JSTL自定义标签
- JSTL自定义标签
- JSTL自定义标签
- 自定义JSTL标签
- JSTL自定义标签
- JSTL 自定义标签
- jstl自定义标签
- 自定义jstl标签库
- 自定义JSTL标签
- jstl自定义标签
- jstl之自定义标签
- 自定义标签JSTL+国际化
- 自定义JSTL标签
- python3--list的使用
- 八大排序方法详解(附java代码)
- Grails项目实现-购物车 过程文档(1)
- 用Maven自动生成带有sh和bat启动脚本的java应用
- loadrunner之资源监控与分析
- jstl自定义标签
- Office2007打开文件提示“您尝试打开的文件xxx.xls的格式与文件扩展名指定的格式不一致”的解决办法
- 集合框架
- 智慧停车市场解决方案
- 生活的烦恼 nsoj
- Attempt to invoke virtual method 'int com.jishang.yunji.ui.ActivityPublishDynamic$DynamicType.ordina
- NYOJ 83-迷宫寻宝(二)(计算几何->线段相交)
- angular2项目下载后运行以及报错,The "@angular/compiler-cli" package was not properly installed
- 手机灭屏之后,来短信或者信息亮屏5s之后再黑屏