標籤: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訪問資料庫並在頁面顯示