自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(33)
  • 收藏
  • 关注

转载 浅析Java中的深拷贝与浅拷贝

首先我们看看浅拷贝和深拷贝的定义    浅拷贝:只复制一个对象,对象内部存在的指向其他对象数组或者引用则不复制    深拷贝:对象,对象内部的引用均复制    为了更好的理解它们的区别我们假设有一个对象A,它包含有2对象对象A1和对象A2     对象A进行浅拷贝后,得到对象B但是对象A1和A2并没有被拷贝    对象A进行深拷贝,得到对象B

2012-11-03 11:38:17 267

转载 Java对数组的复制

定义一个数组int[] a={3,1,4,2,5}; int[] b=a;  数组b只是对数组a的又一个引用,即浅拷贝。 如果改变数组b中元素的值,其实是改变了数组a的元素的值,要实现深度复制,可以用clone或者System.arrayCopy int[] a={3,1,4,2,5};int[] b=a.clone();b[0]=10;System.out.println(b[0

2012-11-03 11:31:01 264

转载 JavaReflect

Get class name for various objectpackage com.dufeng;public class ReflectTest {public static void main(String[] args) {System.out.println(ReflectTest.class.getName());System.out.println(i

2012-10-29 15:14:26 267

转载 java定时器

在某个时间执行某个事件时,在JAVA中目前是有三种方法:第一个是JAVA类中的Timer这个类,也是最常用到的;第二个是ServletContextListener;第三个是用SPRING,org.springframework.scheduling.timer.ScheduledTimerTask也可以。1、java.util.Timer这个方法应该是最常

2012-10-29 12:37:39 327

转载 DateUtils

DateUtils.Truncateimport java.util.Calendar;import java.util.Date;import org.apache.commons.lang.time.DateFormatUtils;import org.apache.commons.lang.time.DateUtils;public class MainClass

2012-10-26 15:16:12 930

转载 StringUtils

StringUtils.trimToEmptyimport org.apache.commons.lang.StringUtils;public class MainClass {    public static void main(String[] args) {      //If string is null, empty string returned. Else

2012-10-26 14:51:34 378

转载 HttpURLConnection

Get the date of a url connectionimport java.net.HttpURLConnection;import java.net.URL;import java.util.Date;public class Main{  public static void main(String args[]) throws Exception {

2012-10-26 13:53:16 1076

转载 explain the HttpURLConnection connection process

try { // instantiate the URL object with the target URL of the resource to request URL url = new URL("http://www.example.com/comment"); // instantiate the HttpURLConnection w

2012-10-26 13:06:27 351

转载 How to use HttpURLConnection POST data to web server?

public static String excutePost(String targetURL, String urlParameters) { URL url; HttpURLConnection connection = null; try { //Create connection url = new URL(targetURL); c

2012-10-26 12:42:31 281

转载 Java小技巧:关于Cookie的操作

测试环境:JDK1.5、Tomcat5.5  1.设置Cookie  1Cookie cookie = new Cookie("key", "value");  2cookie.setMaxAge(60); //设置60秒生存期,如果设置为负值的话,则为浏览器进程Cookie(内存中保存),关闭浏览器就失效。  3cookie.setPath("/test/test

2012-10-25 17:07:52 243

转载 Java对象的序列化和反序列化实践

当两个进程在进行远程通信时,彼此可以发送各种类型的数据。无论是何种类型的数据,都会以二进制序列的形式在网络上传送。发送方需要把这个Java对象转换为字节序列,才能在网络上传送;接收方则需要把字节序列再恢复为Java对象。   把Java对象转换为字节序列的过程称为对象的序列化。  把字节序列恢复为Java对象的过程称为对象的反序列化。  对象的序列化主要有两种用途:

2012-10-25 17:00:23 219

转载 详细解析Java中抽象类和接口的区别

在Java语言中, abstract class 和interface 是支持抽象类定义的两种机制。正是由于这两种机制的存在,才赋予了Java强大的 面向对象能力。abstract class和interface之间在对于抽象类定义的支持方面具有很大的相似性,甚至可以相互替换,因此很多开发者在进 行抽象类定义时对于abstract class和interface的选择显得比较随意。其实,两者之

2012-10-25 16:34:17 356

转载 Java 泛型的理解与等价实现

泛型是Java SE 1.5的新特性,泛型的本质是参数化类型,也就是说所操作的数据类型被指定为一个参数。这种参数类型可以用在类、接口和方法的创建中,分别称为泛型类、泛型接口、泛型方法。  Java语言引入泛型的好处是安全简单。  在Java SE 1.5之前,没有泛型的情况的下,通过对类型Object的引用来实现参数的“任意化”,“任意化”带来的缺点是要做显式的强制类型转换,而

2012-10-25 16:18:28 251

原创 Struts2ActionErrorActionMessageExample

ActionError是用来发送错误信息给用户,通过展示 ActionMessage用来发送信息给用户,通过展示 Properties文件LoginAction.properties#Welcome messageswelcome.hello = Hello #error messag

2012-10-24 14:51:51 366

原创 WorkingWithStruts2Actions

struts2 actions不需要你实现接口和继承任何类,他仅仅需要你实现一个execute方法,它返回一个字符串,按时返回哪个结果页面package com.dufeng.action; public class LoginAction{  //business logic public String execute() { return "success"; }

2012-10-24 14:07:25 234

原创 HowToRemoveTheActionSuffixExtensionInStruts2

pages/printStruts2.jsp 为了访问SayStruts2,适用下面的urlAction URL : http://localhost:8080/Struts2Example/SayStruts2.action配置action extension    pages/printStruts2.jsp

2012-10-24 13:58:01 238

原创 Struts2DevelopmentModeExample

在struts2开发中,你可以提升你的开发速度,如:自动配置,properties文件从加载,和额外的logging和debugging默认情况下,struts2 develop模式是关闭的。Enable the struts2 development modestruts.propertiesstruts.devMode = truestruts.xml

2012-10-24 13:47:43 707

原创 Struts2NamespaceConfigurationExample

Namespace configurationstruts.xml<!DOCTYPE struts PUBLIC"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN""http://struts.apache.org/dtds/struts-2.0.dtd">   pages/welc

2012-10-24 13:34:56 223

原创 IncludeMultipleStrutsConfigurationFiles

一个struts配置文件struts.xml<!DOCTYPE struts PUBLIC"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN""http://struts.apache.org/dtds/struts-2.0.dtd">    pages/welcome_aud

2012-10-24 10:06:40 243

原创 Struts2@ResultPathAnnotationExample

在struts2中,@ResultPath annotation是用来控制struts2在哪里找储存的jsp页面,默认它找jsp页面在WEB-INF/content/目录中@ResultPath example一个action类,设置/user为namespace,跳转到/pages/login.jsp页面@Namespace("/User")@Result(name="succ

2012-10-24 09:58:54 1343 1

原创 Strust2HelloWorldAnnotation

struts2注解需要struts2 convention plugin,所以你必须要理解Scanning Methodology 和Naming Converter原理strust2扫描特定的包名struts,strust2,action,actions扫描怎么工作:扫描特定的类,放在struts,strust2,action或者actions扫描符合下面条件之一的:实现 c

2012-10-24 09:42:27 285

原创 Struts2HelloWorldExample

在这个例子中,我们将创建一个helloworld例子用Struts2下面的工具会被使用:Maven3Eclipse3.7Struts2.3.1.2用maven下载全部的struts2的依赖,在pom.xml中添加struts2-coreFile : pom.xml<project xmlns="http://maven.apache.org/POM/4.0.0"

2012-10-23 22:56:37 187

转载 Missing indirectly referenced artifact com.sun:tools:jar:1.5.0:system

Eclipse的maven:出现Missing indirectly referenced artifact com.sun:tools:jar:1.5.0:system  错误,是因为需要jdk的tools。根本原因是没有指定javaw.exe的的位置,在eclipse.ini中用-vm指定javaw的位置就可以了。 下面是:eclipse.ini中的内容:

2012-10-23 18:43:24 411

原创 SpringMVC+FreeMarker(FTL)Integration example

File: /WebContent/WEB-INF/web.xmlxmlversion="1.0"encoding="UTF-8"?>web-appxmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"        xmlns="http://java.sun.com/xml/ns/javae

2012-10-10 16:43:45 1251

原创 FreeMarker(FTL) Hello World Tutorial with Example

File: src/helloworld.ftlFreeMarker Template example: ${message}   ==========================  County List   ===========================<#list countries as country>

2012-10-10 16:25:54 748

原创 SpringMVC HashMap Form Integration example

File:/WebContent/WEB-INF/web.xmlxmlversion="1.0"encoding="UTF-8"?>web-appxmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    xmlns="http://java.sun.com/xml/ns/javaee"

2012-10-10 16:00:18 952

原创 Saving/Retreving BLOB object in Spring3MVC and Hibernate

CREATETABLE `documents` (  `id`int(11)NOTNULL AUTO_INCREMENT,  `name`varchar(200)NOTNULL,  `description` text NOTNULL,  `filename`varchar(200)NOTN

2012-10-10 14:56:30 553

原创 Create Spring3MVC Hibernate3 Example using Maven in Eclipse

CREATETABLE CONTACTS(    id          INTPRIMARY KEY AUTO_INCREMENT,    firstname   VARCHAR(30),    lastname   VARCHAR(30),    telephone  VARCHAR(15),    email

2012-10-10 13:15:56 434

原创 Spring3MVC:Themes in Spring-Tutorial with Example

我们的目的为了改变Hello World Spring3MVC,添加对主题的支持,用户将可以选择主题从预定义的主题中,(default,black,blue)添加主题支持,在spring3MVC中添加下面的代码到spring-servlet.xml中File: WebContent/WEB-INF/spring-servlet.xmlbeanid="themeS

2012-10-10 09:34:59 258

原创 Spring3MVC:Internationlization&Localization Tutorial with Example

我们将会创建两个properties文件,他们包含显示的所有信息,这些文件被放在叫做resources的目录中,Right click on Project name > New > Source Folder and name it resources.创建两个文件:messages_en.properties和messages_de.properties在这个目录中,拷贝下面的

2012-10-09 18:03:51 354

原创 Spring3MVC:tiles plugin Tutorial with Example in Eclipse

为了配置tiles,作为TIles框架的入口TilesConfigure必须在spring-servlet.xml中配置,打开spring-servlet.xml从WEB-INF的目录中,添加下面的代码在之间File: /WebContent/WEB-INF/spring-servlet.xmlbeanid="viewResolver"    class="

2012-10-09 17:18:44 414

原创 Spring3MVC:Handling Forms in Spring 3.0 MVC

我们的目的是为了创建一个简单的关系管理应用,这个程序将用表单获得关系信息,然后将信息打印到控制台上,我们将学习怎么样不活表单数据用Spring3MVC让我们开始添加关系表单从我们的Spring3MVC Hello World application,打开index.jsp,改变它:File: WebContent/index.jspjsp:forwardpage="contac

2012-10-09 16:11:30 320

原创 Spring3MVC:Create Hello World application in Spring 3.0 MVC

1为了创建Hello world demo application,我们将使用Eclipse IDE。2准备工作: 在开始我们的Hello World SpringMVC Example之前,我们需要一些工具 1 JDK 1.5 以上 2 Tomcat 5.x以上或者其他的容器(Glassfish,JBoss,Websphere,Weblogic etc) 3 Eclipse 3.2.x以上 4

2012-10-09 15:20:19 275

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除