改变Eclipse默认编码

windows –> preferences –> General –> Content types –> Text tree –> Jsp 我们设置最下面的Default Encoding为UTF-8即可.
Read More »

常用的PHP系统在nginx下的伪静态规则

常用的系统在nginx下的伪静态规则。

Read More »

Struts 2注解实例二

这个例子将继续前面讲的例子
Read More »

Struts 2注解实例一

本文将通过一个前台通过表单输入user,来实现hello user的方式来讲述Struts2中使用注解。
Read More »

在windows上安装nginx+php环境

目前,nginx以其独特的性能越来越博得喜爱,LNMP环境逐步代替了LAMP环境。Nginx从v0.7.52也开始支持windows环境。接下来简要介绍些安装方法。
Read More »

使用Properties文件来对Log4j进行配置

Log4j will be usually configured using a properties file or xml file externally. So once the log statements are in place you can easily control them using the external configuration file without modifying the source code. Now let’s see how you can obtain the same log output as the previous example using the properties file configuration.
Log4j通常采用一个properties文件或者xml文件从外部进行配置。所以一旦你需要更改日志的声明,只需要修改外部文件而不必修改源代码。现在,让我们看看如何使用一个properties配置文件来实现前面的例子,得到一样的输出结果。

Read More »

简单的Log4j配置

在struts2的网站上看到一个不错的网站:http://www.vaannila.com 看到里面的一些文章很不错。从今天开始陆续翻译一些文章。今天开始翻译Log4j。

Log4j is a simple and flexible logging framework. In this tutorial you will learn how to configure log4j for your applications. Let’s get started first download the latest version of log4j ( Download ). I am using log4j version 1.2.15. Add the log4j-1.2.15.jar to the classpath.
Log4j是一个简单而且灵活的日志记录框架,在这教程中,我们将学习到在你的应用中如何对log4j进行配置。首先下载最新的版本log4j(下载)。我使用的是1.2.15版本。将Jar包log4j-1.2.15.jar 加入类路径。

Next you need to create an instance of Logger class. You can create one using the Logger.getLogger(HelloWorld.class) method. It takes one argument the fully qualified class name.
接下来,我们需要创建一个Logger类实例。我们可以创建一个使用Logger.getLogger(Helloworld.class)的方法。该方法需要传递一个类的完整名字。

Now we need to configure log4j. The simple way to do that is using BasicConfigurator. configure() method. This will log all the messages on the console.
现在,我们需要配置下log4j。简单的方法是使用BasicConfigurator. configure() 方法。这将会在控制台输出记录的所有信息。

Now everything is ready you can log messages using any of the print statements of the Logger class. In the following code I use the debug() method to display the “HelloWorld!” message.
现在,所有的都准备好了。我们可以使用Logger类中任何的输出方式来记录这些消息。在接下来的代码中,我使用debug的方法来显示“Helloworld!”的信息。

package comvaannilahelloworld;
import orgapachelog4jBasicConfigurator;
import orgapachelog4jLogger;  

public class HelloWorld {     

	static final Logger logger = LoggergetLogger(HelloWorld.class);

	public static void main(String[] args) {
		BasicConfiguratorconfigure();
		loggerdebug("Hello World!");
	}
}

The other methods available are info(), warn(), error() and fatal(). Each method represents a logger level namely DEBUG, INFO, WARN, ERROR and FATAL.
The following example shows how to use these methods.
此外,还可以使用 info(), warn(), error() and fatal()等方法。每个方法代表了一个日志记录级别分别为: DEBUG, INFO, WARN, ERROR and FATAL.
接下里的一个例子将演示如何使用这些方法

package comvaannilahelloworld;
import orgapachelog4jBasicConfigurator;
import orgapachelog4jLogger; 

public class HelloWorld {
	static final Logger logger = LoggergetLogger(HelloWorldclass);
	public static void main(String[] args) { 

		BasicConfiguratorconfigure(); 

		loggerdebug("Sample debug message"); 

		loggerinfo("Sample info message"); 

		loggerwarn("Sample warn message"); 

		loggererror("Sample error message"); 

		loggerfatal("Sample fatal message"); 

	}
}

Here is the output of the above code.
以上代码输出的结果如下:

0 [main] DEBUG comvaannilahelloworldHelloWorld  - Sample debug message
0 [main] INFO comvaannilahelloworldHelloWorld  - Sample info message
0 [main] WARN comvaannilahelloworldHelloWorld  - Sample warn message
0 [main] ERROR comvaannilahelloworldHelloWorld  - Sample error message
0 [main] FATAL comvaannilahelloworldHelloWorld  - Sample fatal message

The output contains the time elapsed from the start of the program in milliseconds, the thread name, the logger level, the class name and the log message.
输出的信息包含程序执行所使用的毫秒,线程名,日志级别,类名和日志信息。

You can download the log4j configuration file here.
你可以下载这个例子
Source :Download
Source + Lib :Download

该文章翻译自:http://www.vaannila.com/log4j/log4j-configuration.html

Hibernate3错误:could not initialize proxy – no Session的解决办法

前段时间在项目中出现以下错误:

org.hibernate.LazyInitializationException: could not initialize proxy - no Session
at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:57)
at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:111)

Read More »

PHP获取客户端IP的几种方法

PHP获取客户端IP有几个函数,下面介绍下三种常用的写法。
Read More »

jqGrid基础学习:6jqGrid中方法使用

jqGrid的方法一般用法如下:


grid_id 是已经实现定义好的jqGrid。
jqGridMethod 是要应用到jqGrid的方法。
parameter1,…parameterN - 一系列方法。
Read More »