惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

W
WeLiveSecurity
T
Tenable Blog
Project Zero
Project Zero
C
Cybersecurity and Infrastructure Security Agency CISA
T
The Exploit Database - CXSecurity.com
P
Palo Alto Networks Blog
S
Schneier on Security
Scott Helme
Scott Helme
S
Securelist
Know Your Adversary
Know Your Adversary
Vercel News
Vercel News
IT之家
IT之家
V
V2EX
F
Fortinet All Blogs
Simon Willison's Weblog
Simon Willison's Weblog
K
Kaspersky official blog
博客园_首页
T
Tailwind CSS Blog
The GitHub Blog
The GitHub Blog
Spread Privacy
Spread Privacy
Microsoft Security Blog
Microsoft Security Blog
Cisco Talos Blog
Cisco Talos Blog
The Register - Security
The Register - Security
有赞技术团队
有赞技术团队
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Cyberwarzone
Cyberwarzone
Google DeepMind News
Google DeepMind News
The Hacker News
The Hacker News
L
LINUX DO - 热门话题
Hugging Face - Blog
Hugging Face - Blog
博客园 - 三生石上(FineUI控件)
A
Arctic Wolf
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
C
CXSECURITY Database RSS Feed - CXSecurity.com
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
T
Threat Research - Cisco Blogs
P
Proofpoint News Feed
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
P
Privacy & Cybersecurity Law Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
C
CERT Recently Published Vulnerability Notes
S
SegmentFault 最新的问题
AWS News Blog
AWS News Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
罗磊的独立博客
Apple Machine Learning Research
Apple Machine Learning Research
P
Proofpoint News Feed
The Cloudflare Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
Vulnerabilities – Threatpost

博客园 - 消失的风

富文本编辑器vue2-editor实现全屏功能 使用Mist部署Contract到Rinkeby以太坊网络 基于以太坊的Token开发步骤 技术顾问认知(一) Angularjs-项目搭建 Augularjs-起步 appfuse:Excel导出 基于JQuery实现的文本框自动填充功能 Appfuse:权限控制 Appfuse:记录操作日志 Appfuse:扩展自己的GenericManager Appfuse:第一张表维护 Appfuse:起步 JAVA实现图片裁剪 Mybatis基于注解的方式访问数据库 敏捷开发与jira之研发管理模式 敏捷开发与jira之阶段工作项概述 敏捷开发与jira之燃烧图 敏捷开发与jira之流程
Appfuse:添加自定义页面组件
消失的风 · 2015-07-17 · via 博客园 - 消失的风

我之前是做ASP.NET的,碰到被多个页面都使用的类似组件后,就想着采用ascx(用户自定义组件)来解决,那做Java我也想用这种方案。

我要做的效果如下:

实现方案:tag方式(自定义标签)

1. 首先定义自己的tag

 1 <%@ tag body-content="scriptless" pageEncoding="UTF-8"%>
 2 <%@ attribute name="table" required="true"%>
 3 <%@ attribute name="idfield" required="true"%>
 4 <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
 5 <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
 6 <c:set var="base" value="${pageContext.request.contextPath}" />
 7 <c:set var="typeList" />
 8 <script src="<c:url value="/scripts/jquery/jquery.1.10.2.min.js" />"></script>
 9 <form method="post">
10     <div id="divRecomment">
11         <fmt:message key="recomment.title" />
12         &nbsp;&nbsp;
13         <select id="recommendAction" name="recommendAction">
14             <c:forEach items="${recommenttype}" var="t">
15                 <option value="${t.key}">${t.value}</option>
16             </c:forEach>
17         <select>
18         &nbsp;&nbsp; <input type="button" onclick="handleRecomment();"
19             value='<fmt:message key="recomment.submit"/>' class="btn btn-primary" />
20     </div>
21 </form>

recommend.tag

2. 使用自定义的标签

<%@ taglib prefix="t" tagdir="/WEB-INF/tags" %>

<t:recommend table="" idfield=""></t:recommend>

3. recommenttype 的数据源:使用页面对应的Controller中的handleRequest

1 HashMap<String,String> recommentType = new HashMap<String,String>();
2         recommentType.put("1", "首页");  
3         recommentType.put("2", "其他");   
4         request.setAttribute(Constants.RECOMMENT_TYPE, recommentType);

handleRequest

附用到的样式

1 #divRecomment{
2     margin-left:12px;
3 }
4 #divRecomment select{
5     width:200px;
6     height:38px;
7     border:1px solid #cccccc;
8 }

main.css