- 浏览: 82229 次
- 性别:
- 来自: 天津
-
最新评论
-
may小张:
很管用!谢谢分享!
设置JTable的列宽 -
xiangyufangai:
谢谢 非常好
Struts2 Ajax -
lydawen:
lydawen 写道justry 写道这位大哥!
小弟不想使用 ...
Struts2 Ajax -
lydawen:
justry 写道这位大哥!
小弟不想使用 struts2内置 ...
Struts2 Ajax -
zhuzhu1124:
谢谢,学习了
Struts2 Ajax
文章列表
hibernate中get方法和load方法的根本区别在于:
如果你使用load方法,hibernate认为该id对应的对象(数据库记录)在数据库中是一定存在的,所以它可以放心的使用,它可以放心的使用代理来延迟加载该对象。在用到对象中的其他属性数据时才查询数据库,但是万一数据库中不存在该记录,那没办法,只能抛异常,所说的load方法抛异常是指在使用该对象的数据时,数据库中不存在该数据时抛异常,而不是在创建这个对象时。由于session中的缓存对于hibernate来说是个相当廉价的资源,所以在load时会先查一下session缓存看看该id对应的对象是否存在,不存在则创建代理。所以如果你知道该 ...
- 2009-01-13 22:04
- 浏览 930
- 评论(0)
Apache Lucene is a high-performance, full-featured text search engine library written entirely in Java. It is a technology suitable for nearly any application that requires full-text search, especially cross-platform.
/**
* 这个实例包含了lucene所有核心用法
*/
public class LuceneTest {
public static vo ...
- 2008-12-07 14:39
- 浏览 869
- 评论(0)
使用enum可以方便的替代常量类。
/**enum可以单独定义*/
public enum Week {
SUNDAY,MONDAY,TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY
}
public class ENUMTest {
/**enum也可以定义在class里面*/
public enum Color{RED,ORANGLE,YELLO,GREEN,CYAN,BLUE,PURPLE}
public static void main(String[] args){
for(Week w:Wee ...
- 2008-12-07 14:18
- 浏览 2891
- 评论(0)
public class Customer implements Serializable{
private static final long serialVersionUID = 1L;
private long id;
private String name = "Mike";
private int age = 20;
/**私有构造器也能通过反射访问*/
private Customer(){
}
public Customer(String name,int age){
this.na ...
- 2008-12-07 14:10
- 浏览 935
- 评论(0)
代理模式是给一个对象提供代理,以控制对它的访问,如只有授权用户才可以访问某个对象,给对象添加日志、事务功能。
JDK动态代理是提供运行时实现代理模式的一种方法,但是只支持接口类型。
Cglib可以支持类的代理。
/**业务接口*/
public interface IHello {
public void hello(String name);
}
/**业务接口实现*/
public class HelloSpeaker implements IHello {
@Override
public void hello(String name) {
...
- 2008-12-07 13:45
- 浏览 1193
- 评论(0)
public class Test{
public static void main(String[] args) {
String str=new String("ABC");
}
}
它的虚拟机指令集:
Compiled from "Test.java"
public class Test extends java.lang.Object{
public Test();
Code:
0: aload_0
1: invokespecial #1; //Method ...
- 2008-12-06 11:58
- 浏览 1282
- 评论(0)
public class AuthImg extends HttpServlet
{
private static final long serialVersionUID = 1L;
private Font mFont = new Font("Arial Black", Font.PLAIN, 16);
public void init() throws ServletException
{
super.init();
}
Color getRandColor(int fc,int bc)
...
- 2008-12-05 00:35
- 浏览 997
- 评论(0)
public class StartupListener extends ContextLoaderListener
implements ServletContextListener {
private static final Log log = LogFactory.getLog(StartupListener.class);
private IMaintainService maintainService;
public void setMaintainService(IMaintainService maintainService) {
...
- 2008-12-05 00:33
- 浏览 3667
- 评论(0)
public class SecurityByMD5 {
private static final String[] HEXDIGITS = {"0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f&quo ...
- 2008-12-05 00:28
- 浏览 949
- 评论(0)
Acegi默认不支持RBAC权限模型,需要自己扩展。对于数据的获取默认是SQL,也需要扩展。
public class RdbmsEntryHolder implements Serializable{
private static final long serialVersionUID = 2317309106087370323L;
//保护的URL模式
private String url;
//要求的角色集合
private ConfigAttributeDefinition cad;
public String getUrl() {
...
- 2008-12-05 00:26
- 浏览 1320
- 评论(0)
以前写的坦克大战的启动代码。
public class Splash extends JFrame{
private static final long serialVersionUID = 1L;
JPanel panel = new JPanel();
JLabel lblIcon = new JLabel(new ImageIcon("images/boot.jpg"));
public JProgressBar bar = new JProgressBar();
public boolean status = true;
Timer t ...
- 2008-12-05 00:17
- 浏览 975
- 评论(0)
public class JTableUtil {
//自动设置列宽
public static void fitTableColumns(JTable table) {
JTableHeader header = table.getTableHeader();
int rowCount = table.getRowCount();
Enumeration columns = table.getColumnModel().getColumns();
while (columns.hasMoreElements()) {
TableColumn co ...
- 2008-12-05 00:08
- 浏览 10490
- 评论(1)
自己写的Jdbc模板,使用了Template,Strategy,Call Back等,可以自动设置参数,并可以完成ResultSet到JTable以及List的自动映射。极大减少重复代码,比较经典。
PreparedStatementCallback 是用于回调的接口
public interface PreparedStatementCallback {
public Object doInPreparedStatement(PreparedStatement pstmt) throws SQLException,ClassNotFoundException;
}
pu ...
- 2008-12-04 23:59
- 浏览 2906
- 评论(1)
Digester package lets you configure an XML -> Java object mapping module, which triggers certain actions called rules whenever a particular pattern of nested XML elements is recognized. A rich set of predefined rules is available for your use, or you can also create your own.
映射XML对象
public cla ...
- 2008-12-04 23:26
- 浏览 1688
- 评论(1)
以前用CVS的时候,一个新的项目需要频繁修改,还有很多文件、包、初始测试文件需要移除,这些对于项目搭建的辅助部分和正式的开发版本是不一样的,应该从DEV Version中移除,然后构建一个Version1的CVS项目。
记得刚开始大家都手动去删除Entries,Repository,Root这些东西,并且项目的任何一个位置都有这烦人的东东,后来我终于受不了,自己写了一个工具类来递归删除它们,重新构建Version1的项目。尽管现在自己开发时都用SVN不用CVS了,还是贴出来共享吧。
public class DeleteFile {
private static Strin ...
- 2008-11-30 23:57
- 浏览 1020
- 评论(0)