所有非byte类型的基本类型都可以通过String.valueOf() 方法来转换为字符串
非基本类型的比较需要使用equals方法
取得表单提交的参数值
1: String name = request.getParameter('Name');
取得表单提交的数组值
1: String[] nameList = request.getParameterValues('ListName');
向页面传递参数
1: request.setAttribute('var',value);
Session操作
1: session.setAttribute('var',value);
2: session.getAttribute('var');
3: session.removeAttribute('var');
把字符串分割为数组
1: String[] col= MyStr.split(',');
判断数组的长度
1: MyList.length;
把字符串转换为整型
1: Integer.parseInt(Str);
在JSP页面中输出传递值
1: <bean:write name='Obj' property='Id' /> //对象的某个属性
2: <bean:write name='name' />
Map操作方法
1: Map condition= new HashMap();
2: condition.put('name', value);
3: condition.get('name');
日期格式化
1: Date date= new Date();
2: SimpleDateFormat df= new SimpleDateFormat('yyyy-MM-dd');
3: String today = df.format(date); //把日期型转换为字符串
4: Date day = df.parse('2005-08-09');
动态字符串方法 StringBuffer buffer= new StringBuffer(100);
下面两个算是比较高级的使用了
日期相减的方法
1: import java.util.*;
2: public class DateSubtraction{
3: public static void main(String [] args){
4: Calendar cal = Calendar.getInstance();
5: cal.set(2000, Calendar.AUGUST, 24);
6: Date d1 = cal.getTime();
7: cal.set(2000, Calendar.AUGUST, 28);
8: Date d2 = cal.getTime();
9: long daterange = d2.getTime() - d1.getTime();
10: long time = 1000*3600*24; //A day in milliseconds
11: System.out.println(daterange/time);
12: }
13: }
取得内存的使用情况
1: public class MemoryStats{
2: public static void main(String args[]){
3: long totalMem = Runtime.getRuntime().totalMemory();
4: long freeMem = Runtime.getRuntime().freeMemory();
5: System.out.println('Total memory'+ totalMem);
6: System.out.println('Free memory' + freeMem);
7: }
8: }
1: String name = request.getParameter('Name');
取得表单提交的数组值
1: String[] nameList = request.getParameterValues('ListName');
向页面传递参数
1: request.setAttribute('var',value);
Session操作
1: session.setAttribute('var',value);
2: session.getAttribute('var');
3: session.removeAttribute('var');
把字符串分割为数组
1: String[] col= MyStr.split(',');
判断数组的长度
1: MyList.length;
把字符串转换为整型
1: Integer.parseInt(Str);
在JSP页面中输出传递值
1: <bean:write name='Obj' property='Id' /> //对象的某个属性
2: <bean:write name='name' />
Map操作方法
1: Map condition= new HashMap();
2: condition.put('name', value);
3: condition.get('name');
日期格式化
1: Date date= new Date();
2: SimpleDateFormat df= new SimpleDateFormat('yyyy-MM-dd');
3: String today = df.format(date); //把日期型转换为字符串
4: Date day = df.parse('2005-08-09');
动态字符串方法 StringBuffer buffer= new StringBuffer(100);
下面两个算是比较高级的使用了
日期相减的方法
1: import java.util.*;
2: public class DateSubtraction{
3: public static void main(String [] args){
4: Calendar cal = Calendar.getInstance();
5: cal.set(2000, Calendar.AUGUST, 24);
6: Date d1 = cal.getTime();
7: cal.set(2000, Calendar.AUGUST, 28);
8: Date d2 = cal.getTime();
9: long daterange = d2.getTime() - d1.getTime();
10: long time = 1000*3600*24; //A day in milliseconds
11: System.out.println(daterange/time);
12: }
13: }
取得内存的使用情况
1: public class MemoryStats{
2: public static void main(String args[]){
3: long totalMem = Runtime.getRuntime().totalMemory();
4: long freeMem = Runtime.getRuntime().freeMemory();
5: System.out.println('Total memory'+ totalMem);
6: System.out.println('Free memory' + freeMem);
7: }
8: }