雜記-格式化Date預設格式,日期加一天,jstl判斷字元類型,ajax類比from表單後台跳轉頁面,jstl訪問資料庫並在頁面顯示

來源:互聯網
上載者:User

標籤:item   document   mat   stl   解決   跳轉頁面   後台   格式化   drive   

1.格式化Date預設格式

     String str="Sun Oct 08 22:36:45 CST 2017";        SimpleDateFormat sdf = new SimpleDateFormat ("EEE MMM dd HH:mm:ss Z yyyy", Locale.UK);        Date date = null;        try {            date = sdf.parse(str);        } catch (ParseException e) {            e.printStackTrace();        }        SimpleDateFormat sdf2=new SimpleDateFormat("yyyy-MM-dd");        String sDate=sdf2.format(date);        System.out.println(sDate);

2.日期加一天

     // 日期加一天        Format f = new SimpleDateFormat("yyyy-MM-dd");            Date today = new Date();            Calendar c = Calendar.getInstance();            c.setTime(today);            c.add(Calendar.DAY_OF_MONTH, 1);// 今天+1天            Date tomorrow = c.getTime();            sj = f.format(tomorrow);

3.jstl不能對字元類型進行判斷,解決方案,將字元轉成int對比數字

     // el判斷char字元報錯如下,由此可見轉為了long類型,如果是數字可以判斷,字元不行        Cannot convert A of type class java.lang.String to class java.lang.Long

4.ajax訪問後台無法像提交form表單一樣在後台跳轉頁面,解決方案,js動態建立表單

       //ajax訪問後台無法向form表單一樣跳轉頁面,解決方案,動態建立表單        function formSubmit(a,b,c,d,e) {            var turnForm = document.createElement("form");               //一定要加入到body中!!               document.body.appendChild(turnForm);            turnForm.method = ‘post‘;            turnForm.action = ‘bk/jumpToDetail‘;            turnForm.target = ‘_self‘;            //建立隱藏表單            var newElement = document.createElement("input");            newElement.setAttribute("ksid",b);            newElement.setAttribute("rq",e);            newElement.setAttribute("ghlb",c);            newElement.setAttribute("sxwbz",d);            newElement.setAttribute("sjd",a);            turnForm.appendChild(newElement);                        turnForm.submit();        }

5.jstl訪問資料庫並在頁面顯示

    <sql:setDataSource var="snapshot" driver="oracle.jdbc.driver.OracleDriver" url="jdbc:oracle:thin:@192.168.1.8:1521:dbname" user="account"  password="pwd"/>       <sql:query dataSource="${snapshot}" var="result">           select * from tablename       </sql:query>

     <table>
      <c:forEach var="row" items="${result.rows}">
        <tr>
          <td><c:out value="${row.id}"/></td>
          <td><c:out value="${row.name}"/></td>
          <td><c:out value="${row.url}"/></td>
        </tr>
      </c:forEach>
    </table>

 

雜記-格式化Date預設格式,日期加一天,jstl判斷字元類型,ajax類比from表單後台跳轉頁面,jstl訪問資料庫並在頁面顯示

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.