1. Formatting the default format of the 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. Date Plus Day
// date plus one day
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); // today + 1 day
Date tomorrow = c.getTime ();
sj = f.format (tomorrow);
3.jstl cannot judge a character type, solve a problem, convert a character to an int comparison number
// el judges that the char character is reported as follows, which shows that it is converted to long type.
Cannot convert A of type class java.lang.String to class java.lang.Long
4.ajax access to the background can not be like submitting form forms in the background jump page, workaround, JS dynamic creation of forms
// The ajax access background cannot jump to the page like the form form, the solution is to dynamically create the form
function formSubmit (a, b, c, d, e) {
var turnForm = document.createElement ("form");
// Must be added to the body! !!
document.body.appendChild (turnForm);
turnForm.method = ‘post’;
turnForm.action = ‘bk / jumpToDetail’;
turnForm.target = ‘_self’;
// Create hidden form
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 accessing the database and displaying it on the page
<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>
Notes-format date default format, date plus day, Jstl judge character type, Ajax simulation from form background jump page, JSTL Access database and display on page