- 浏览: 30755 次
- 性别:
- 来自: 深圳
文章分类
- 全部博客 (47)
- MyEclipse集成本地Tomcat (2)
- JSP指令元素 (1)
- JSP动作元素 (1)
- JSP内置对象 (1)
- JSP和JavaBean (1)
- EL表达式 (1)
- JSTL标签库 (1)
- Servlet开发基础 (1)
- Filter开发 (1)
- Listener开发 (1)
- DAO设计模式 (1)
- MVC (1)
- JAVA面试智力题 (1)
- ORACLE 数据库 (4)
- JAVA开发应用 (1)
- web前端 (2)
- 数据库 (3)
- SVN更新的时候前面的U与G是什么意思? (1)
- oracle通过约束名查看表名的方法 (1)
- TOMCAT 配置 (1)
- 表空间使用及修改大小 (1)
- Oracle function (1)
- 数据库、DBLINK (1)
- Spring AOP (2)
最新评论
自定义标签
页面设定标签内容:
<td align="center">
<bean:define id="credentialId" name="result" property="credentialId"></bean:define>
<zclshtmlx:credentialTime credentialId='${credentialId}'></zclshtmlx:credentialTime>
</td>
<td align="center">
<zclshtmlx:contractEndDate credentialId='${credentialId}'></zclshtmlx:contractEndDate>
</td>
标签内容:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
"http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">
<taglib>
<tlib-version>1.3</tlib-version>
<jsp-version>1.2</jsp-version>
<short-name>bean</short-name>
<uri>http://localhost/tags-bean</uri>
<!-- 左菜单 -->
<tag>
<name>leftTag</name>
<tag-class>com.platform.util.tag.tag.LeftMenuTag</tag-class>
<body-content>JSP</body-content>
<attribute>
<name>moduleId</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>moduleCode</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
<!-- 证件类型 -->
<tag>
<name>displayCredentialTypeJspTag</name>
<tag-class>
com.platform.util.tag.type.CredentialTypeJspTag
</tag-class>
<body-content>JSP</body-content>
<description>Displays the Top Jsp</description>
<attribute>
<name>url</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
<!-- 资料类型树 -->
<tag>
<name>displayMaterialTypeJspTag</name>
<tag-class>
com.platform.util.tag.type.MaterialTypeJspTag
</tag-class>
<body-content>empty</body-content>
</tag>
<!-- 人事组织机构树 -->
<tag>
<name>displayQueryPersonTreeJspTag</name>
<tag-class>
com.platform.util.tag.tag.QueryPersonTreeJspTag
</tag-class>
<body-content>empty</body-content>
<description>Displays the Top Jsp</description>
</tag>
<!-- 总部下面的单位树 -->
<tag>
<name>displayDirectUnitTreeJspTag</name>
<tag-class>
com.platform.util.tag.tag.DisplayDirectUnitTreeTag
</tag-class>
<body-content>empty</body-content>
<description>Displays the Top Jsp</description>
</tag>
<!-- 总部下面的单位部门树 -->
<tag>
<name>displayUnitDeptTreeJspTag</name>
<tag-class>
com.platform.util.tag.tag.DisplayUnitDeptTreeTag
</tag-class>
<body-content>empty</body-content>
<description>Displays the Top Jsp</description>
<attribute>
<name>url</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
<!-- 角色信息管理-单位树菜单 -->
<tag>
<name>DisplayUnitTreeJspTag</name>
<tag-class>
com.platform.util.tag.tag.DisplayUnitTreeJspTag
</tag-class>
<attribute>
<name>url</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
<tag>
<name>write</name>
<tag-class>com.platform.util.tag.struts.taglib.bean.WriteTag</tag-class>
<body-content>JSP</body-content>
<attribute>
<name>bundle</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>filter</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>format</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>formatKey</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>ignore</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>locale</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>name</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>property</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>scope</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>len</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>withDot</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>moneyFormat</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>upperFormat</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
<tag>
<name>dateImg</name>
<tag-class>com.platform.util.tag.tag.DateImageTag</tag-class>
<body-content>JSP</body-content>
<attribute>
<name>bundle</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>filter</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>format</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>formatKey</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>ignore</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>name</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>property</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>scope</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>days</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>src</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>is_less</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
<tag>
<name>auth</name>
<tag-class>com.platform.util.tag.tag.AuthPermissionTag</tag-class>
<body-content>JSP</body-content>
<attribute>
<name>function</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>noFunction</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>module</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>noModule</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
<!-- 判断项目种类 -->
<tag>
<name>verifyProjectSort</name>
<tag-class>com.platform.util.tag.tag.VerifyProjectSortTag</tag-class>
<body-content>JSP</body-content>
<attribute>
<name>projectId</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
<!-- 申请单审批人 -->
<tag>
<name>approvalPerson</name>
<tag-class>com.platform.util.tag.tag.FreeApprovalPersonTag</tag-class>
<body-content>JSP</body-content>
<attribute>
<name>approvalId</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
<!-- 已审批-->
<tag>
<name>reApproval</name>
<tag-class>com.platform.util.tag.tag.FreeReApprovalTag</tag-class>
<body-content>JSP</body-content>
<attribute>
<name>approvalId</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>objectName</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
<!-- 查询流程IDS-->
<tag>
<name>queryApprovalIds</name>
<tag-class>com.platform.util.tag.tag.QueryFreeApprovalIdsTag</tag-class>
<body-content>JSP</body-content>
<attribute>
<name>approvalId</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>objectName</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
<!-- 查询业务申请单待批事项-->
<tag>
<name>applyApprovalItem</name>
<tag-class>com.platform.util.tag.tag.QueryApplyApprovalItemTag</tag-class>
<body-content>JSP</body-content>
<attribute>
<name>approvalId</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
<!-- 工作流参数设置的单位部门树 -->
<tag>
<name>processDeptPostTreeJspTag</name>
<tag-class>
com.platform.workflow.util.tag.ProcessDeptPostTreeTag
</tag-class>
<body-content>empty</body-content>
<attribute>
<name>resource</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>url</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
<!-- 建造师合同时间显示 -->
<tag>
<name>constructorTime</name>
<tag-class>com.platform.util.tag.tag.ConstructorContractTimeTag</tag-class>
<body-content>JSP</body-content>
<attribute>
<name>constructorId</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
<!-- 人员合同时间显示 -->
<tag>
<name>personContractTime</name>
<tag-class>com.platform.util.tag.tag.PersonContractTimeTag</tag-class>
<body-content>JSP</body-content>
<attribute>
<name>personId</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
<!-- 证件到期时间显示 -->
<tag>
<name>credentialTime</name>
<tag-class>com.platform.util.tag.tag.CredentialTimeTag</tag-class>
<body-content>JSP</body-content>
<attribute>
<name>credentialId</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
<!-- 证件合同止期到期时间显示 -->
<tag>
<name>contractEndDate</name>
<tag-class>com.platform.util.tag.tag.CredentialContractEndDateTag</tag-class>
<body-content>JSP</body-content>
<attribute>
<name>credentialId</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
</taglib>
对应标签实现类:
package com.platform.util.tag.tag;
import java.util.Date;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;
import com.platform.base.spring.SpringContextUtil;
import com.platform.operate.credentials.pojo.Credential;
import com.platform.operate.credentials.service.CredentialInfoService;
import com.platform.util.common.DateUtil;
import com.platform.util.common.StringUtil;
import com.platform.util.constants.Constants;
/** ========================================================
* 上海建业信息科技有限公司 研发中心
* 日 期:2013-7-18 下午03:05:19
* 作 者:张俊奎
* 版 本:1.0
* 功能描述:证件到期时间显示
*
* 修订日期 修订人 描述
* 2013-7-18 张俊奎 创建
* ========================================================
*/
public class CredentialContractEndDateTag extends TagSupport{
private Long credentialId;
public int doEndTag() throws JspException
{
try
{
JspWriter out = pageContext.getOut();
HttpServletRequest request = (HttpServletRequest)pageContext.getRequest();
HttpSession session = request.getSession();
Object obj = session.getAttribute(Constants.SESSION_USER_OBJ);
Date nowTime = new Date();//当前时间
nowTime= StringUtil.DateToDate(nowTime, "yyyy-MM-dd");
if(obj == null){
out.write("请重新登录");
return super.doEndTag();
}
String endTimeStr = "";
if(StringUtil.isNotNullOrBlank(credentialId)){
CredentialInfoService credentialInfoService = (CredentialInfoService)SpringContextUtil.getBean("credentialInfoService");//bean的名称
Credential credential = (Credential) credentialInfoService.getObject(Credential.class,credentialId);
if(credential!=null&&StringUtil.isNotNullOrBlank(credential.getContractEndDate())){
//判断时间范围
Integer nowTimeInt = Integer.parseInt(StringUtil.DateToString(nowTime, "yyyyMMdd"));//当前时间
Integer endDateInt = Integer.parseInt(StringUtil.DateToString(credential.getContractEndDate(), "yyyyMMdd"));//结束时间
if(endDateInt<nowTimeInt){
//获取过期天数
int days1 = DateUtil.daysBetween(credential.getContractEndDate(), nowTime)+1;
endTimeStr = "<font style='font-weight:bold;color: red' title='本证件合同止期已过期,合同止期期限:"+StringUtil.DateToString(credential.getContractEndDate(), "yyyy年MM月dd日")+"'>已过期("+days1+")天</font>";
}else{
//获取到期天数
int days = DateUtil.daysBetween(nowTime, credential.getContractEndDate())+1;
if(days<90){
endTimeStr = "<font style='color: red;' title='距离合同止期不足三个月'>"+StringUtil.DateToString(credential.getContractEndDate(), "yyyy.MM.dd")+"</font>";
}else{
endTimeStr = StringUtil.DateToString(credential.getContractEndDate(), "yyyy.MM.dd");
}
}
}
}
out.write(endTimeStr);
}
catch (Exception ex)
{
throw new JspException(ex);
}
return super.doEndTag();
}
/**
* @return the credentialId
*/
public Long getCredentialId() {
return credentialId;
}
/**
* @param credentialId the credentialId to set
*/
public void setCredentialId(Long credentialId) {
this.credentialId = credentialId;
}
}
<td align="center">
<bean:define id="credentialId" name="result" property="credentialId"></bean:define>
<zclshtmlx:credentialTime credentialId='${credentialId}'></zclshtmlx:credentialTime>
</td>
<td align="center">
<zclshtmlx:contractEndDate credentialId='${credentialId}'></zclshtmlx:contractEndDate>
</td>
标签内容:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
"http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">
<taglib>
<tlib-version>1.3</tlib-version>
<jsp-version>1.2</jsp-version>
<short-name>bean</short-name>
<uri>http://localhost/tags-bean</uri>
<!-- 左菜单 -->
<tag>
<name>leftTag</name>
<tag-class>com.platform.util.tag.tag.LeftMenuTag</tag-class>
<body-content>JSP</body-content>
<attribute>
<name>moduleId</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>moduleCode</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
<!-- 证件类型 -->
<tag>
<name>displayCredentialTypeJspTag</name>
<tag-class>
com.platform.util.tag.type.CredentialTypeJspTag
</tag-class>
<body-content>JSP</body-content>
<description>Displays the Top Jsp</description>
<attribute>
<name>url</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
<!-- 资料类型树 -->
<tag>
<name>displayMaterialTypeJspTag</name>
<tag-class>
com.platform.util.tag.type.MaterialTypeJspTag
</tag-class>
<body-content>empty</body-content>
</tag>
<!-- 人事组织机构树 -->
<tag>
<name>displayQueryPersonTreeJspTag</name>
<tag-class>
com.platform.util.tag.tag.QueryPersonTreeJspTag
</tag-class>
<body-content>empty</body-content>
<description>Displays the Top Jsp</description>
</tag>
<!-- 总部下面的单位树 -->
<tag>
<name>displayDirectUnitTreeJspTag</name>
<tag-class>
com.platform.util.tag.tag.DisplayDirectUnitTreeTag
</tag-class>
<body-content>empty</body-content>
<description>Displays the Top Jsp</description>
</tag>
<!-- 总部下面的单位部门树 -->
<tag>
<name>displayUnitDeptTreeJspTag</name>
<tag-class>
com.platform.util.tag.tag.DisplayUnitDeptTreeTag
</tag-class>
<body-content>empty</body-content>
<description>Displays the Top Jsp</description>
<attribute>
<name>url</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
<!-- 角色信息管理-单位树菜单 -->
<tag>
<name>DisplayUnitTreeJspTag</name>
<tag-class>
com.platform.util.tag.tag.DisplayUnitTreeJspTag
</tag-class>
<attribute>
<name>url</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
<tag>
<name>write</name>
<tag-class>com.platform.util.tag.struts.taglib.bean.WriteTag</tag-class>
<body-content>JSP</body-content>
<attribute>
<name>bundle</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>filter</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>format</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>formatKey</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>ignore</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>locale</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>name</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>property</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>scope</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>len</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>withDot</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>moneyFormat</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>upperFormat</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
<tag>
<name>dateImg</name>
<tag-class>com.platform.util.tag.tag.DateImageTag</tag-class>
<body-content>JSP</body-content>
<attribute>
<name>bundle</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>filter</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>format</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>formatKey</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>ignore</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>name</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>property</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>scope</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>days</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>src</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>is_less</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
<tag>
<name>auth</name>
<tag-class>com.platform.util.tag.tag.AuthPermissionTag</tag-class>
<body-content>JSP</body-content>
<attribute>
<name>function</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>noFunction</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>module</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>noModule</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
<!-- 判断项目种类 -->
<tag>
<name>verifyProjectSort</name>
<tag-class>com.platform.util.tag.tag.VerifyProjectSortTag</tag-class>
<body-content>JSP</body-content>
<attribute>
<name>projectId</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
<!-- 申请单审批人 -->
<tag>
<name>approvalPerson</name>
<tag-class>com.platform.util.tag.tag.FreeApprovalPersonTag</tag-class>
<body-content>JSP</body-content>
<attribute>
<name>approvalId</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
<!-- 已审批-->
<tag>
<name>reApproval</name>
<tag-class>com.platform.util.tag.tag.FreeReApprovalTag</tag-class>
<body-content>JSP</body-content>
<attribute>
<name>approvalId</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>objectName</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
<!-- 查询流程IDS-->
<tag>
<name>queryApprovalIds</name>
<tag-class>com.platform.util.tag.tag.QueryFreeApprovalIdsTag</tag-class>
<body-content>JSP</body-content>
<attribute>
<name>approvalId</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>objectName</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
<!-- 查询业务申请单待批事项-->
<tag>
<name>applyApprovalItem</name>
<tag-class>com.platform.util.tag.tag.QueryApplyApprovalItemTag</tag-class>
<body-content>JSP</body-content>
<attribute>
<name>approvalId</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
<!-- 工作流参数设置的单位部门树 -->
<tag>
<name>processDeptPostTreeJspTag</name>
<tag-class>
com.platform.workflow.util.tag.ProcessDeptPostTreeTag
</tag-class>
<body-content>empty</body-content>
<attribute>
<name>resource</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>url</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
<!-- 建造师合同时间显示 -->
<tag>
<name>constructorTime</name>
<tag-class>com.platform.util.tag.tag.ConstructorContractTimeTag</tag-class>
<body-content>JSP</body-content>
<attribute>
<name>constructorId</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
<!-- 人员合同时间显示 -->
<tag>
<name>personContractTime</name>
<tag-class>com.platform.util.tag.tag.PersonContractTimeTag</tag-class>
<body-content>JSP</body-content>
<attribute>
<name>personId</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
<!-- 证件到期时间显示 -->
<tag>
<name>credentialTime</name>
<tag-class>com.platform.util.tag.tag.CredentialTimeTag</tag-class>
<body-content>JSP</body-content>
<attribute>
<name>credentialId</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
<!-- 证件合同止期到期时间显示 -->
<tag>
<name>contractEndDate</name>
<tag-class>com.platform.util.tag.tag.CredentialContractEndDateTag</tag-class>
<body-content>JSP</body-content>
<attribute>
<name>credentialId</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
</taglib>
对应标签实现类:
package com.platform.util.tag.tag;
import java.util.Date;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;
import com.platform.base.spring.SpringContextUtil;
import com.platform.operate.credentials.pojo.Credential;
import com.platform.operate.credentials.service.CredentialInfoService;
import com.platform.util.common.DateUtil;
import com.platform.util.common.StringUtil;
import com.platform.util.constants.Constants;
/** ========================================================
* 上海建业信息科技有限公司 研发中心
* 日 期:2013-7-18 下午03:05:19
* 作 者:张俊奎
* 版 本:1.0
* 功能描述:证件到期时间显示
*
* 修订日期 修订人 描述
* 2013-7-18 张俊奎 创建
* ========================================================
*/
public class CredentialContractEndDateTag extends TagSupport{
private Long credentialId;
public int doEndTag() throws JspException
{
try
{
JspWriter out = pageContext.getOut();
HttpServletRequest request = (HttpServletRequest)pageContext.getRequest();
HttpSession session = request.getSession();
Object obj = session.getAttribute(Constants.SESSION_USER_OBJ);
Date nowTime = new Date();//当前时间
nowTime= StringUtil.DateToDate(nowTime, "yyyy-MM-dd");
if(obj == null){
out.write("请重新登录");
return super.doEndTag();
}
String endTimeStr = "";
if(StringUtil.isNotNullOrBlank(credentialId)){
CredentialInfoService credentialInfoService = (CredentialInfoService)SpringContextUtil.getBean("credentialInfoService");//bean的名称
Credential credential = (Credential) credentialInfoService.getObject(Credential.class,credentialId);
if(credential!=null&&StringUtil.isNotNullOrBlank(credential.getContractEndDate())){
//判断时间范围
Integer nowTimeInt = Integer.parseInt(StringUtil.DateToString(nowTime, "yyyyMMdd"));//当前时间
Integer endDateInt = Integer.parseInt(StringUtil.DateToString(credential.getContractEndDate(), "yyyyMMdd"));//结束时间
if(endDateInt<nowTimeInt){
//获取过期天数
int days1 = DateUtil.daysBetween(credential.getContractEndDate(), nowTime)+1;
endTimeStr = "<font style='font-weight:bold;color: red' title='本证件合同止期已过期,合同止期期限:"+StringUtil.DateToString(credential.getContractEndDate(), "yyyy年MM月dd日")+"'>已过期("+days1+")天</font>";
}else{
//获取到期天数
int days = DateUtil.daysBetween(nowTime, credential.getContractEndDate())+1;
if(days<90){
endTimeStr = "<font style='color: red;' title='距离合同止期不足三个月'>"+StringUtil.DateToString(credential.getContractEndDate(), "yyyy.MM.dd")+"</font>";
}else{
endTimeStr = StringUtil.DateToString(credential.getContractEndDate(), "yyyy.MM.dd");
}
}
}
}
out.write(endTimeStr);
}
catch (Exception ex)
{
throw new JspException(ex);
}
return super.doEndTag();
}
/**
* @return the credentialId
*/
public Long getCredentialId() {
return credentialId;
}
/**
* @param credentialId the credentialId to set
*/
public void setCredentialId(Long credentialId) {
this.credentialId = credentialId;
}
}
相关推荐
在实际开发中,有时我们需要根据项目需求实现特定的功能,比如动态生成SQL或者进行复杂的业务逻辑处理,这时MyBatis的自定义标签功能就显得尤为重要。 自定义标签是MyBatis框架的一大特色,它允许我们扩展XML映射...
在Struts2中,自定义标签是提高代码可读性和可维护性的重要工具。本文将深入探讨Struts2自定义标签的实现机制、优点以及如何在实际项目中进行应用。 一、Struts2自定义标签的概念 自定义标签是JSP的一种扩展,允许...
在JavaServer Pages (JSP) 技术中,自定义标签是扩展JSP功能的关键手段,它允许开发者创建可重用的组件,提高代码的可维护性和可读性。本实例将深入探讨如何实现一个简单的JSP自定义标签。 首先,自定义标签的实现...
在ThinkPHP中,自定义标签(Tag Lib)是一种强大的特性,允许开发者扩展模板引擎的功能,使其更符合项目需求。下面将详细解释如何在ThinkPHP 3.0版本中实现自定义标签及其使用方法。 1. **自定义标签的作用** ...
一个“自定义标签”是开发者为了扩展JSP(JavaServer Pages)功能而创建的,它允许我们封装复杂逻辑并将其作为可重用的组件。本项目提供了一个用于分页的自定义标签,适用于那些需要在网页上进行数据分页展示的应用...
本篇文章将详细阐述如何在CKEditor 4.0中进行自定义标签操作,并提供经过修改的编辑器JAR包供下载。 CKEditor 4.0是一款开源的JavaScript富文本编辑器,它支持多种浏览器环境,提供丰富的功能和高度可定制性。...
在Java Server Pages (JSP) 2.0版本中,自定义标签和自定义标签函数极大地扩展了JSP开发的灵活性和可重用性。这些特性允许开发者创建可复用的组件,使代码更加清晰,易于维护。本文将深入探讨JSP 2.0中的自定义标签...
在Spring框架中,自定义标签是一项非常实用的功能,它允许我们创建符合XML语法的自定义元素,以便在配置文件中更方便地表达业务逻辑。在"spring自定义标签例子"这个项目中,我们可以深入理解这一特性,特别是通过...
本案例通过JavaScript来实现自定义标签的功能。具体而言,它通过遍历文档中的内容,将自定义的标签转换为标准的HTML标签,并应用相应的样式。下面我们将详细介绍其实现细节。 #### 自定义标签代码解析 ```...
在JavaServer Pages (JSP) 技术中,自定义标签是提高代码可重用性和模块化的重要手段。自定义标签允许开发者创建自己的组件,这些组件可以像HTML标签一样在页面上使用,使得代码更加清晰易读。本教程将深入探讨JSP...
在 Struts 中,自定义标签是提供一种灵活的方式,使得视图层(通常为 JSP 页面)能够更好地与业务逻辑交互,从而提高代码的可读性和可维护性。本文将深入探讨如何在 Struts 中实现自定义标签。 一、自定义标签概述 ...
在JSP(JavaServer Pages)开发中,自定义标签是一种扩展JSP功能的强大工具,它允许开发者创建可重用的代码组件,以提高代码的可读性和可维护性。本篇学习笔记将深入探讨JSP自定义标签的相关概念、创建方法以及实际...
首先,创建自定义标签的目的是为了增加语义化,使网页内容更易于机器理解,同时提高人类阅读的清晰度。例如,可以定义`<article>`、`<sidebar>`等标签来明确内容区块的类型。自定义标签遵循驼峰式命名规则,如`...
在Java Web开发中,自定义标签(Custom Tags)是一个强大的工具,它允许开发者创建可重用的组件,提高代码的可读性和维护性。自定义标签是JSP标准标签库(JSTL)的一种扩展,它能将复杂的业务逻辑封装起来,使JSP...
Java自定义标签是JavaServer Pages (JSP)技术的一个强大特性,它允许开发者扩展JSP的标准标签库,创建自己的定制化标签,以提高代码的可读性和可维护性。自定义标签可以封装复杂的业务逻辑或者视图呈现,使得页面...
JSP(JavaServer Pages)自定义标签是JSP技术中一个重要的特性,允许开发者创建可重用的、自定义的组件,从而提高代码的可读性和可维护性。本文将深入讲解JSP自定义标签的相关概念、格式、处理过程以及创建和使用...
使用jsp自定义标签的功能实现权限的控制。(如果用户没有某个模块的删除权限,就不现实这个删除按钮) 在整个项目中所有的页面都可以引入自定义的标签去做到权限的控制。 自定义标签文件 删除 可以控制页面中的每...
在这个"Freemarker自定义标签简单案例"中,我们将深入探讨如何利用Freemarker进行模板设计,并结合自定义标签来增强模板的功能。 首先,让我们理解Freemarker的基础知识。Freemarker是一个与语言无关的模板引擎,它...
JSP自定义标签是用户定义的JSP语言元素,可以看成是一种通过标签处理器生成基于XML脚本的方法。自定义标签在功能上和逻辑上都与JavaBean类似,都是一组可重用的组件代码。相较于JavaBean,自定义标签可以使Web开发者...