
Java
stefli
简直就是懒人一个
就喜欢下班回家下碟子,看碟子
听听音乐
展开
-
Convert string to JSONObject by net.sf.json library
Just for reminder.JSONObject json = (JSONObject) JSONSerializer.toJSON( jsonTxt );原创 2011-07-19 18:04:22 · 1738 阅读 · 0 评论 -
Force the system to use the embedded jar
Scenario: There is an old version jar library in the environment, but now i want to use the embedded jar library in my system. Now the jar library is placed under the WEB-INF/lib. The only ste原创 2009-06-24 16:51:00 · 481 阅读 · 0 评论 -
Bind the WebApplicationContext in MockStrutsTestCase
StrutsTestCase is a powerful and conveniont tool for testing behavior of Struts.But there are some difficulties in testing Spring+StrutsTestCase.1. How to bind JNDI without server environment, lik原创 2009-06-17 17:15:00 · 753 阅读 · 0 评论 -
Use jcvsii to get the cvs info
1. Add libraries to the project2. Write the following code to retrieve the info from CVS /** * Get the cvs log * * @param basePath * @param username * @param password * @retur原创 2009-08-14 13:35:00 · 678 阅读 · 0 评论 -
Exception creating bean of class org.apache.struts.validator.DynaValidatorForm: {1}
i encountered a strange exception, the track likes below:====================================================== javax.servlet.jsp.JspException: Exception creating bean of classorg.apache.strut转载 2009-06-02 16:30:00 · 3058 阅读 · 0 评论 -
Using spring to mock a jndi
1. Add spring-mock.jar 2. Configure a datasource in your applicationContext-*.xml 3. Use SimpleNamingContextBuilder to bind the jndi to datasource============================================原创 2009-06-02 17:28:00 · 857 阅读 · 0 评论 -
Show multiple tables in one page by using valueList
First we need speicify a unique name to each tableTable1: Table2: Second we use the name to retrieve the certain specified value list dataTable1:ValueListHandler valueListHa原创 2009-05-21 13:38:00 · 612 阅读 · 0 评论 -
Add Junit to Ant classpath
There are some solutions to add Junit to ANTs classpath:1. Add junit*.jar to the ANTs Global Entries in eclipse2. Add junit*.jar to the JDK/jre/lib/ext (BUT sometimes the build still doesnt run原创 2009-07-23 10:12:00 · 1057 阅读 · 0 评论 -
How to set the style in valuelist
We can easy to set the style of header and body in the valuelist. this.style.backgroundColor=#EFF7F7 this.style.backgroundColor= grid-tr-data 1. we can use 2. we can use att原创 2009-05-07 22:30:00 · 679 阅读 · 0 评论 -
Run the specified server in JBoss
call run -b 192.168.83.98 -c allcall run -b 192.168.83.98 -c productioncall run -b 192.168.83.98 -c default原创 2009-07-17 09:48:00 · 514 阅读 · 0 评论 -
cvs update: move away src *****; it is in the way
If you encounter this issue, please just delete your local files or folders firstthen update it again. the issue will be fixed.原创 2009-07-14 16:15:00 · 1936 阅读 · 0 评论 -
Use Rome to generate the RSS
Rome is a usefull and convenient library for generating RSS. package com.stefli.rss;import java.util.ArrayList;import java.util.List;import com.sun.syndication.feed.rss.Channel;import原创 2009-04-10 15:36:00 · 722 阅读 · 0 评论 -
About the logout in weblogic
References: weblogic.servlet.security.ServletAuthentication.logout() Removes the authentication data from the userss session data, which logs out a user but allows the session to remain al原创 2009-06-25 09:38:00 · 696 阅读 · 0 评论 -
J2EE Web Project configuration
test com.genuitec.eclipse.j2eedt.core.WebClasspathBuilder org.eclipse.jdt.core.javabuilder com.genuitec.eclipse.j2eedt.core.J2EEProjectValidator com.genuit原创 2009-09-01 17:52:00 · 799 阅读 · 0 评论 -
An effective way to use pattern to instead of multiple if else statements
We often face many if-else statements during the development, that's a little boring.We can use pattern to change this, such as Strategy, an原创 2011-07-19 15:14:39 · 770 阅读 · 0 评论 -
How to get bean from tag component
<br />Please refer to:<br />@SuppressWarnings("unchecked") @Override public Component getBean(ValueStack stack, HttpServletRequest request, HttpServletResponse response) { ServletContext servletContext = ServletActionContext .getServletCont原创 2011-05-04 10:09:00 · 836 阅读 · 0 评论 -
事务的传播性
1.Required:共享型若1处在一个事务中调用了2,则2直接和1在同一个事务中。若1没有任何事务,则系统会默认给2创建一个新事务。此策略适合大多数情况。2.RequiredNew:独立型若1在一个事务中调用了2,则系统先将1的事务挂起,不管、之后为2设置一个新事务,执行完毕后恢复1的事务。若1没有事务,则会为2新开一个事务。3.Mandatory:强制共享型若1处在一个转载 2011-06-13 22:02:00 · 815 阅读 · 0 评论 -
Specify the column on one-to-many
If we want the relatioship is TestParent.testNo = TestChild.testNo, do not use the identity column "id".We should specify the columns in mapping file, such as:<class name="com.stefli.model.TestPar原创 2011-06-09 13:56:00 · 743 阅读 · 0 评论 -
How to format date/datetime in struts2
<br />1. Use param<br /><s:textfield name="order.entryDt"> <s:param name="value" ><s:date name="order.entryDt" format="MM/dd/yyyy" /></s:param> </s:textfield> <br /> <br />2. Use i18n, you should enable i18n and add i18n properties first.<br />i18n原创 2011-05-27 11:02:00 · 986 阅读 · 0 评论 -
Customize tag lib 2
<br />We also can customize the tag lib using component class, here are the steps:<br />1. Define the component<br />package com.stefli.core.component.taglib;import java.io.IOException;import java.io.Writer;import javax.servlet.http.HttpServletReques原创 2011-04-02 13:08:00 · 617 阅读 · 0 评论 -
Customize tag lib 1 (freemarker)
Want to customize a tag lib, we need to do follow the steps:1. Define the component (UIBean)package com.stefli.core.component.taglib;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import org.apache.struts2.原创 2011-04-02 13:02:00 · 660 阅读 · 0 评论 -
getString() always return 255 when column is larger than 255
<br />I have created a table with a column(varchar(1200), then insert some data to this table.<br />When use Jdbc to get the value of this column, it always return 255 chars, so, we need to solve<br />it via:<br /> <br />select convert(text, columnName) fr原创 2011-02-18 14:39:00 · 1113 阅读 · 0 评论 -
How to record log of specified package by using log4j
The key is:log4j.logger.packageName[.ClassName]=level[,appender] Quote: http://penghao122.javaeye.com/blog/Reference: 先看一个log4j.properies配置文件:————————————————————我是强大的分割线——————转载 2009-09-30 10:43:00 · 680 阅读 · 0 评论 -
Details of classloader
Quote: http://www.objectsource.com/j2eechapters/Ch21-ClassLoaders_and_J2EE.htm Chapter 21Classloadersand J2EEIn this chapter:1. You will understand why cla转载 2009-09-29 10:39:00 · 902 阅读 · 0 评论 -
Emma.xsl for Cruise Control
Here is an emma.xsl that can be used to show the emma report in Cruise Control. <!-- function openPackage(id) { var obj = document.getElementById(id); obj.style.display = o原创 2009-07-06 15:08:00 · 914 阅读 · 0 评论 -
Guidline of Ant
编译源代码 javac srcdir="src"/>Ant 的 javac 任务的默认行为是调用运行 Ant 本身的任何 JVM 的标准编译器。然而,有时您可能想要单独地调用编译器 ―― 例如当你希望指定编译器的某些内存选项,或者需要使用一种不同级别的编译器的时候。为实现这个目的,只需将 javac 的 fork 属性设置为 true,比如像下面这样:转载 2009-03-20 12:59:00 · 576 阅读 · 0 评论 -
Let weblogic check the modification of jsp automatically
Just configure the weblogic.xml, make the param-value to be 0.========================================================= pageCheckSeconds 0 And set weblogic launch mode to "Debug mo原创 2009-03-06 12:54:00 · 429 阅读 · 0 评论 -
如何使用Proxy模式及Java内建的动态代理机制
版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。http://zhangjunhd.blog.51cto.com/113473/69996 1.Proxy模式代理模式支持将某些操作从实际的对象中分离出来,通过它的代理类提供处理。这样便于修改和管理这些特定的操作。下面示例一个代理模式的实现。<v:shapetyp转载 2008-10-09 20:55:00 · 1168 阅读 · 0 评论 -
How to execute the jar
i want to execute a jar in the console, if the jar doesnt depend external jars, the following command will done.C:/>java -jar test.jarbut if it depends external jars, we should add a line in MANIFEST原创 2008-10-24 14:59:00 · 690 阅读 · 0 评论 -
Some experiences in axis.
There is a perfect tool called "soapUI",it can help you to generate code easily. 1.Add SOAPHeader information in the request. // Set header try { SOAPHeaderElement原创 2008-09-17 17:26:00 · 749 阅读 · 0 评论 -
Spring's transaction configuration
we often use "PROPAGATION_REQUIRED" to config our transaction.but if there throw an exception ,the transaction will not rollback as we expect. so,we should add a special code in the configuratio原创 2008-09-10 10:00:00 · 594 阅读 · 0 评论 -
Base64加密
/** a standard Base64 encoder/decoder. * @author S.Weeden,N.J.Ferrier */public class Base64{ /** decode a Base 64 encoded String. * String to byte conversion * This method us转载 2005-04-13 18:25:00 · 1371 阅读 · 0 评论 -
Jsp中使用xmlhttp进行数据交互~
1.客户端提交请求Domain = " test.com" sXml = "" &_ "" &_ "" & Domain & "" &_ "" Set oD = Server.CreateObject("Microsoft.XMLHTTP") oD.Open "Post", "http://Server/Domain_Check.jsp", False oD.Send(sX原创 2005-01-28 10:11:00 · 1391 阅读 · 0 评论 -
Java操作Xml的小结
文档对象模型 (DOM) 是一个文档标准,对于完备的文档和复杂的应用程序,DOM 提供了大量灵活性。DOM标准是标准的。它很强壮且完整,并且有许多实现。这是许多大型安装的决定因素--特别是对产品应用程序,以避免在API发生改变时进行大量的改写。 以上是我在选择处理XML数据时之所以没有选择JDOM或者dom4j等其它面向对象的标准的原因,不过也由于DOM从一开始就是一种与语言无关的模型,而且它更趋原创 2005-01-17 11:49:00 · 16422 阅读 · 0 评论 -
我的Java学习路四:第一个servlet
注:以下文章来自网络 正如操作系统利用PATH来搜索可执行程序一样,Java运行环境也会遍历CLASSPATH来查找类,即便是HelloWorld这样简单的程序,JVM也会遍历CLASSPATH定义的每一个路径,直到找到相应的文件为止。 相信大家用的系统不是2k就是XP,然后就应当如下设置Path: 我的电脑->属性->高级->环境变量 然后在环境变量的Path后面原创 2004-10-15 21:59:00 · 949 阅读 · 0 评论 -
我的Java学习路五:Sql Server数据库操作
首先安装JSP访问SQL Server 2000的驱动程序: 从微软的网站上下载驱动程序:SQL Server 2000 For JDBC 驱动程序,在Google中随便搜索就有。 然后必须将安装目录中的lib目录下三个jar文件:msbase.jar,mssqlserver.jar,msutil.jar拷贝到Tomcat目录下common/lib目录下。并设置CLASSP原创 2004-10-16 15:21:00 · 1165 阅读 · 0 评论 -
我的Java学习路三:经典HelloWorld
转发一遍来自ChinaJavaWorld论坛的ak47的作品,是截至目前为至我看到的最全的关于Java初门的详细介绍 对于一个java的初学者正确编译HelloWorld程序,才能真正算是进入了java的菜鸟阶段呀。 想起我开始编译HelloWorld程序,会出现各种各样的错误。直到我看到下面这篇文章后终于完成了我的HelloWorld程序。 所以我把这篇文章转载 问HelloWorld问题的人实原创 2004-10-15 15:04:00 · 1148 阅读 · 0 评论 -
我的Java学习路二:邮件发送
String from="**@**.com";String to=**@**.com;try{SmtpClient client = new SmtpClient("mail.**.**");client.from(from);client.to(to);PrintStream message = client.startMessage();message.println("To: " + to原创 2004-10-14 21:21:00 · 1059 阅读 · 0 评论 -
Java HTMLEncode & HTMLDecode
public class TestNBSP { public static void main(String[] args) { String s = " &>"; System.out.println(StringEscapeUtils.unescapeHtml(s)); }}原创 2008-10-10 14:33:00 · 7698 阅读 · 6 评论 -
Could not create task or type of type: junit
The resolve method as below:Add junit-[version].jar to the ants classpath.eclipse->windows->ant->runtime->classpath原创 2008-10-28 17:48:00 · 879 阅读 · 0 评论