1 Looping syntax
for (Rteachersubject teacher:teachersubjectlist)
{System. out. println (Teacher.getteacherclasssubjectid ());
}
2 MySQL Syntax
SELECT DISTINCT TSC. ClassID, CONCAT (Tsc.grade, ' Grade ', tsc.name) as ClassName from
Cloud_archivesmanage.t_teacherinfo TTi
JOIN
Cloud_archivesmanage.r_teacher_subject RTS on TTi. Userid=rts. Teacherid
JOIN Cloud_archivesmanage.t_schoolclass TSC on TSC. Classid=rts. ClassID
WHERE TTi. userid=13969823
In SQL Server
SELECT DISTINCT TSC. ClassID, CAST (Tsc.grade as
VARCHAR) + ' grade ' +tsc.name as ClassName from
Cloud_ArchivesManage.dbo.T_TeacherInfo TTi
JOIN
Cloud_ArchivesManage.dbo.R_Teacher_Subject RTS on TTi. Userid=rts. Teacherid
JOIN Cloud_ArchivesManage.dbo.T_SchoolClass TSC on TSC. Classid=rts. ClassID
WHERE TTi. userid=13969823
3 Condition Judgment
<if test="SSID! = null and ssid!=" and ssid!= '-1 ' ">
and TSS. ssid=#{SSID, Jdbctype=varchar}
</if>
4 Database IsNull and ifnull issues
In sql: ISNULL (s.num,0) as Studentnumber
In MySQL: Ifnull (s.num,0) as Studentnumber
5 Problems in Mybatits
Pay attention to the return type when seeking the total quantity
6 instantiation problems
list<rclassversion> classversionlist = new arraylist<rclassversion> ();
7 Self-growth ID is null
8 Database type for datetime
TIMESTAMP
9 Reasons for reading less data
LIMIT 0,3 default starting from 0
Ten like query
and SCC. Name like CONCAT ('% ', ' ${classname} ', '% ')
11 Get the day of the month
Calendar cal = Calendar. getinstance ();
Int day=cal.get (Calendar. DATE));
12 Regular parsing
String regex = "\\{[^\\{*].*\\}";
Pattern pattern = pattern. Compile (regex);
Matcher Matcher = Pattern.matcher (res);
Jsonobject jsonobject = jsonobject.fromobject (matcher.group (0));
JSON parsing
Jsonobject jsonobject = Jsonobject. Fromobject (Matcher.group (0));
Nested data inside data
Jsonarray ja1 = Jsonobject.getjsonarray ("Data");
list<productinfo> Product = new arraylist<productinfo> ();
Try {
for (int i = 0; i < ja1.size (); i++) {
Jsonobject Jsonitem = Ja1.getjsonobject (i);
ProductInfo item = new productinfo ();
Item.setproductid (Jsonitem.getint ("ProductID"));
Item.setproductname (jsonitem.getstring ("ProductName"));
Item.setstatus (Jsonitem.getint ("Status"));
Item.setlogoimg (jsonitem.getstring ("logoimg"));
Item.seturl (jsonitem.getstring ("Url"));
Product.add (item);
}
} catch (Jsonexception e) {
E.printstacktrace ();
}
A layer of data
String regex = "\\{[^\\{*].*\\}";
Pattern pattern = pattern. Compile (regex);
Matcher Matcher = Pattern.matcher (res);
if (Matcher.find ()) {
Jsonobject jsonobject = Jsonobject. Fromobject (Matcher.group (0));
Try {
if (Jsonobject.getint ("Code") = = && Jsonobject.getboolean ("Data") {
Json.setmessage (jsonobject.getstring ("Message"));
Json.seturl (URL);
Json.setstate (true);
} Else {
Json.setmessage (jsonobject.getstring ("Message"));
Json.seturl (URL);
Json.setstate (false);
}
} catch (Jsonexception e) {
E.printstacktrace ();
}
}
Substring
String str = url.substring (Url.length ()-1, Url.length ());
from which to the end, to who?
The question of Jdbctype not to write
D_type = #{awbtype,jdbctype=varchar} The Jdbctype does not write any impact
Answer: Do not write as empty will error, write it will not
16 Chinese characters converted to GB2312 method
Public String Changecharset (String str, string newcharset) throws unsupportedencodingexception {
if (str = null) {
Decodes a string with the default character encoding.
byte [] bs = Str.getbytes ();
Generate a string with a new character encoding
return New String (BS, Newcharset);
}
return null;
}
17 string Concatenation method
C#
string res = string. Format ("key={0}&userid={1}&productid={2}&datatype={3}&name={4}&schoolid={5}", Key, UserID, ProductId, "JSON", Usercentername, Schoolareaid)
Java implementation
String param1 = string. format ("Key=%1$s&userid=%2$s&productid=%3$s&datatype=%4$s&name=%5$s&schoolid=%6$s", Key, UserID,
ProductId, "JSON", Usercentername, Schoolareaid);
%s String type such as "Mingrisoft"
%c character type ' m '
%b Boolean type True
%d integer type (decimal) 99
%x integer type (hexadecimal) FF
%o Integer type (octal) 77
%f floating-point type 99.99
%a hexadecimal floating-point type Ff.35ae
%e Index Type 9.38e+5
%g General floating-point types (shorter in type F and e)
Percent% type%
%n line break
%tx Date and Time type (x represents a different date and time conversion character)
Why Tomcat failed to start
Mapper.xml problems, case-sensitive
Problems encountered in Java real-world development (differs from net)