²»ÓÃspring,hibernate³¬Éµ¹ÏJAVA¿ª·¢(javabean+Êý×é)
javabean+Êý×éÓŵ㣺
1¡¢¼òµ¥£ºjava³ÌÐòÖÐ×î¼òµ¥µÄÀàιýÓÚjavabean£¬javabeanÓÐÒ»Ì׳ÉÊìµÄ¹æ·¶£¬Ò×ÓÚ±àд
2¡¢·½±ã£ºjavabeanÊÇÊý¾ÝµÄÔØÌ壬¼È¿ÉÒÔͨ¹ýsetºÍget·½Ê½À´²Ù×÷Êý¾Ý£¬ÓÖ¿ÉÒÔÏóʹÓÃÊý×éÒ»ÑùÀ´²Ù×÷javabean
3¡¢Í¨ÓãºÍ¨¹ýϱêÀ´²Ù×÷javabean£¬ÄãËùдµÄ´úÂ뽫ÊÇͨÓõģ¬¿ÉÒÆÖ²µÄ¡£ÄãËùдµÄ¹¦ÄÜ×é¼þ½«ÊÊÓÃÓÚËùÓеÄjavabean
4¡¢0ÅäÖãºÍ¨¹ýÊý×éÀ´¶Ôjavabean½øÐÐ˵Ã÷ÅäÖ㬱ÈXMLÎļþ¸üÇåÎú
5¡¢Ò×ÓÚÐ޸ģº³ÌÐòÖв»ÔÙÓÐÈκÎSQLÓï¾ä£¬Êý¾Ý½á¹¹·¢Éú¸Ä±ä£¬Ö»ÒªÐÞ¸Äjavabean¼´¿É
6¡¢Ò×ÓÚά»¤£ºÓÉÓÚµÚ3µãµÄͨÓÃÐÔ£¬ÄãÖ»ÐèҪά»¤Ò³Ãæ¼°²Ù×÷Âß¼¡£
7¡¢Éµ¹ÏÐÔ£º»á²Ù×÷Êý×é¾Í»áʹÓã¬ËùÒÔûÓÐÈκÎѧϰÇúÏß
ʾÀý£º
package com.askyear.demo.bean;
import java.util.Date;
import com.askyear.db.ATable;
import com.askyear.db.key.String32Key;
/**
* Óû§
*
* @author askyear.com
*
*/
public class User extends ATable {
public static final String USER_SESSION = "user";
private static final long serialVersionUID = -8942196092377147945L;
private String member;
private String name;
private String password;
private String email;
private String type;
private Boolean useable;
private Date createTime;
public User() {
this.initSelf();
}
public void buildKeyIfNull() {
if (this.member == null || this.member.length() == 0) {
this.member = String32Key.getKeyValue();
}
if (this.useable == null)
this.useable = true;
if (this.createTime == null)
this.createTime = new Date();
}
public Object getPropertyValue(int index) {
switch (index) {
case 0:
return member;
case 1:
return name;
case 2:
return password;
case 3:
return email;
case 4:
return type;
case 5:
return useable;
case 6:
return createTime;
default:
throw new ArrayIndexOutOfBoundsException("·ÃÎÊÔ½½ç:" + index);
}
}
public void initSelf() {
this.setTableName("sys_user");
this.setTableChinaName("ϵͳÓû§");
key = new int[] { 0 };
property = new String[] { "member", "name", "password", "email", "type", "useable", "createTime" };
field = n
Ïà¹ØÎĵµ£º
½Ó¿Ú±¾ÖÊÉϾÍÊÇÓÉÖÆ¶¨ÕßÀ´Ðµ÷ʵÏÖÕߺ͵÷ÓÃÕßÖ®¼äµÄ¹ØÏµ¡£
ËùÒÔͨ³£ËµµÄ“ÃæÏò½Ó¿Ú±à³Ì”¿ÉÒÔÀí½âΪ£º
Ö»ÓÐʵÏÖÕߺ͵÷ÓÃÕß¶¼×ñÑ“ÃæÏò½Ó¿Ú±à³Ì”Õâ¸ö×¼Ôò£¬Öƶ¨ÕßµÄе÷Ä¿µÄ²ÅÄÜ´ïµ½¡£
Ò»¸öÀÏÉú³£Ì¸µÄÀý×Ó¾ÍÊÇJDBC¡£
ºÜ¶àÈ˷ѽ⣺¼ÈÈ»ÎÒÿÁ¬½ÓÒ»ÖÖÊý¾Ý¿â£¨Èçmysql£©¶¼ÒªÊÂÏȲ¿ÊðÇý¶¯³ÌÐò£¬ÄÇÎÒÖ±½ ......
import java.util.Properties;
public class ConfigReader {
private static Properties cache = new Properties();
static{
try {
cache.load(ConfigReader .class.getClassLoader().getResourceAsStream("config.properties"));
} catch (Exception e) {
&nbs ......
³ÌÐòÉè¼ÆÖо³£»áÅöµ½ÓÃ×é¼þÀ´ÏÔʾͼƬµÄÇé¿ö, ¿ÉÒÔÏÔʾͼƬµÄ×é¼þÓкܶà,Èçawt°üÖеÄbutton,label,panelµÈ¶¼¿ÉÒÔÔÚÆäÉÏÃæ·ÅÖÃͼƬ.ͼƬÓÖ¿É·ÖΪÁ½Àà,Ò»ÀàÊÇ·ÅÖÃÓÚbuttonµÈ×é¼þÉϵÄImageIcon(ͼ±ê),ÁíÒ»ÀàÊÇ¿ÉÒÔ·ÅÖÃÔÚpanelµÈ×é¼þÉϵĽϴóµÄͼƬImage¡£
´Ó±¾µØ¼ÆËã»úÖжÁȡͼƬµÄ·½·¨Ò²Óкܶ࣬±ÈÈ磬 ......
package test;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
public class Test {
public static void main(String arg[]) {
String fileName = "E:\\share\\test.txt";
File file = new File(fileName);
......
package test;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
public class Test {
public static void main(String arg[]) {
String fileName = "E:\\share\\test.txt";
String writeData = "HelloWorld!\r\nnihaoÎÒµÄ ......