The jsp jstl function declares page variables with tags for use by jstl, time format problem

Jsp jstl function declare page variables with tags for use by jstl, time format problem

  <%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>

 

  <!-- Declare the split function-->

<c:set var="splitTempPath" value="${fn:split(vo.tempPath, '/')}" />

/// This variable can be referenced anywhere else

<a target='${random.nextInt(1000)}'

href='${pageContext.request.contextPath}${vo.tempPath}'

style='height: 16px; float: left'> <span> ${splitTempPath[2]}</span></a>

 

<c:when test="${fn:length(item.publishContent)>20}">${fn:substring(item.publishContent,0,20)}...</c:when>

 

 

<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>

<td><fmt:formatDate value="${item.chkTime}" pattern="yyyy-MM-dd HH:mm:ss" /></td>

 

Time format issue:

Only the automatically generated xml is TIMESTAMP special, the rest are date

page:

<input type="text" name="start_add_time" class="date" value='<fmt:formatDate value="${vo.start_add_time}" pattern="yyyy-MM-dd"/>'/>

 

Model driven:

  @Column(name = "START_ADD_TIME")

   private Date start_add_time;

   

 

   @Column(name = "END_ADD_TIME")

   private Date end_add_time;

 

java

 

When encountering dates in alphabetical format, use

public static final String PATTERN_DATE = "yyyy-MM-dd";

SimpleDateFormat sdf = new SimpleDateFormat(PATTERN_DATE);

if(tbClientLogVo.getStart_add_time()!=null&&!"".equals(tbClientLogVo.getStart_add_time())){

        param.put("START_ADD_TIME", sdf.format(tbClientLogVo.getStart_add_time()));

        }

 

xml:(自动生成的即可)

<result column="OPM_TIME" property="opmTime" jdbcType="TIMESTAMP" />///只有此处特殊

 

//比较时间的话用 tochar()

<select id="getLogList" parameterType="map" resultMap="BaseResultMapVo">

   SELECT t.LOG_KEY,

       t.OPM_TIME,

       t.OPM_DETAIL,

       t.WORK_MODULE,

       NVL(T1.MAN, T2.CUSTOMER_NAME) MAN,

       t1.CUS_USER_ID

   FROM TB_CLIENT_LOG t, TB_CUS_USER t1, TB_CUS_FIRM T2

   where t.CUS_USER_KEY = t1.CUS_USER_KEY AND

       T.CUSTOMER_KEY = T2.CUSTOMER_KEY

    <if test="CUS_USER_ID!=null and CUS_USER_ID!=''">

     AND lower(trim(T1.CUS_USER_ID))  LIKE lower(trim('%${CUS_USER_ID}%'))

    </if>

    <if test="START_ADD_TIME!=null and START_ADD_TIME!=''">

      AND to_char(T.Opm_Time,'yyyy-mm-dd') <![CDATA[>=]]> #{START_ADD_TIME}

    </if>

    <if test="END_ADD_TIME!=null and END_ADD_TIME!=''">

       AND to_char(T.Opm_Time,'yyyy-mm-dd') <![CDATA[<=]]> #{END_ADD_TIME}

    </if>

     order by t.OPM_TIME DESC

  </select>

 

 

数据库:

OPM_TIME  DATE

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326487942&siteId=291194637