- 浏览: 29168 次
- 性别:
- 来自: 深圳
文章分类
- 全部博客 (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;
}
}
相关推荐
介绍了mybatis自定义标签,添加自定义标签的实现代码,通过实例代码展示给大家
本人自行研究JSP自定义标签的学习笔记 目录如下: 目录 一、概述 1 1.1 使用简单标签机制 2 1.2 使用标签文件 3 二 、自定义标签简介 3 2.1 自定义标签概念 3 2.2 标签相关概念 3 2.3 如何创建自定义标签 3 三、自...
java自定义标签java自定义标签java自定义标签java自定义标签java自定义标签java自定义标签
JSP自定义标签是用户定义的JSP语言元素,可以看成是一种通过标签处理器生成基于XML脚本的方法。自定义标签在功能上和逻辑上都与JavaBean类似,都是一组可重用的组件代码。相较于JavaBean,自定义标签可以使Web开发者...
jsp 自定义标签 一个简单的自定义标签实现
JSP自定义标签。在自定义标签的起始和结束标签之间的部分为标签体(Body)。 标签处理程序类:定义标签的行为,并在JSP引擎遇到自定义标签时调用执行。 标签库描述符(TLD)文件:描述标签库的XML文档,向JSP引擎...
JSP自定义标签JSP自定义标签JSP自定义标签JSP自定义标签JSP自定义标签JSP自定义标签
通过struts2 自定义标签实例,可以用这个对项目中的实现自定义标签。从而减少代码。
JSTL 以及自定义标签开发相关 JSTL 核心标签库标签共有13个,功能上分为4类: 1.表达式控制标签:out、set、remove、catch 2.流程控制标签:if、choose、when、otherwise 3.循环标签:forEach、forTokens 4.URL...
Struts2中实现自定义标签很简单,主要分为3步: 1.创建taglib文件(.tld),编写标签声明。 2.编写自定义标签类。 3.在页面中使用标签。 下面以一个自定义的分页标签为例,进行说明。 其实,开发自定义标签并不...
使用jsp自定义标签的功能实现权限的控制。(如果用户没有某个模块的删除权限,就不现实这个删除按钮) 在整个项目中所有的页面都可以引入自定义的标签去做到权限的控制。 自定义标签文件 删除 可以控制页面中的每...
用js实现自定义标签,用js实现自定义标签,用js实现自定义标签
自己写的自定义标签库,实现JSTL常用的功能。
java自定义标签java自定义标签java自定义标签java自定义标签java自定义标签java自定义标签java自定义标签java自定义标签
jQuery自定义标签添加删除代码是一款简单实用的自定义添加标签跟删除特效。
里面有thinkphp自定义标签的方法和使用文档
struts实现自定义标签
jsp、jstl自定义标签实现的分页,实现的还是比较好的,没有在request、session等范围保存过数据,在pageContext范围内保存过集合的数据, 实现的方法还是比较简单的,适用性还是比较广的,我是实在是没分了,平时也...
介绍自定义标签的运行原理以及标签可以干哪些事情,简介传统标签与自定义标签的区别