Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » 技术文章库  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 最近工作的一些小tips集合
tier3





发贴: 228
积分: 120
于 2005-08-22 10:01 user profilesend a private message to usersend email to tier3search all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
1.在无网络环境时,要把config-tiles.xml里的dtd文件位置改在本地的文件路径,否则出来IO Error
<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration//EN"
"D:/eclipse/workspace/HMS/WEB-INF/lib/tiles-config.dtd">

18:45:04,046 ERROR [TilesPlugin] Can't create Tiles definition factory for modul
e ''.
18:45:04,046 ERROR [[action]] Allocate exception for servlet action
org.apache.struts.tiles.DefinitionsFactoryException: IO Error while parsing file
'/WEB-INF/config-tiles.xml'. \WEB-INF\lib\tiles-config.dtd


2. 如何从inputstream得到file:
classLoader.getResource() -->inputstream.toURI() --> new File(uri)

URI uri = this.getClass().getClassLoader().getResource("WEB-INF/data/hotelx/rooms").toURI();
File directory = new File(uri);

3. within jsp <%%>
we can not use Vector<***>
it seems jasper can't parse jdk 1.5 syntax??

4. in elicpse plugin development, after you create the action and plugin class in
eclipse wizard, never try to change their names, otherwise, in runtime application,
the classloader will never find the action class.
5. 用<%=request.getContextPath()%>可以取得当前war的名字,
有一个问题。
用"href="<%=request.getContextPath()%>/jsp" 出来的结果是正确的"http://bruce-liu:8080/mdf-gen/jsp",
但是如何用"href="/<%=request.getContextPath()%>/jsp",出来的结果就是""http://mdf-gen/jsp",
所以不能在前面加上"/".

6 exception using junitreport (java.lang.ClassNotFoundException: redirect)
To fix the problem you have the choice to:
- Upgrade your Xalan version to the latest one (or anything 2.4.1+) via the
endorsment mechanism
- Upgrade your JDK to 1.4.2-01+
- Use the ${ant.home}/etc/junit-frames-xalan1.xsl

Any option should fix the problem, this is due to an unfortunate
incompatibility between Xalan versions and the need to support XSLTC in JDK 1.5

http://issues.apache.org/bugzilla/show_bug.cgi?id=30524

7
矢量标识语言(VML),精度图像标识语言(PGML)都是作为W3C的矢量图像初始标准在1998年提出的.
VML和PGML在很多地方非常的类似,但VML比较适合一些普通矢量图像,而PGML可以做出更加丰富多彩,
适合专业设计和公众出版的图像.

  为了进一步促进图像标准的发展,W3C成立了SVG工作组.SVG工作组将VML和PGML的优势结合在了一起,
重新推出了新的标准矢量格式,这就是SVG.
哪些是SVG能做到而GIF,JPEG做不到的?

  SVG较位图图像有很多独特的优势:

  1.任意放缩: 用户可以自由的放缩图像而不会破坏图像的清晰度.
  2.文本独立: SVG图像中的文字独立于图像,可以编辑和查询.同时,也不会再有字体的限制,用户系统即使没有安装某一字体,
同样可以看到这些字体.
  3.较小文件尺寸: 一般而言,SVG图像要比其他网络图像格式如GIF,JPEG更小,下载更迅速.
  4.超强显示效果: SVG图像的清晰度适合任何屏幕分辨率或打印分辨率(dpi),无论是300dpi,600dpi甚至更高,
都不会产生位图图像的马赛克现象.
  5.超强色彩控制: SVG图像具有一个1600万色彩的调色板,支持ICC标准,RGB,线性填充和遮罩.
  6.超强交互性: 由于SVG是基于XML的,因而能制作出空前强大的动态交互.SVG图像能对用户动作做出不同响应,
例如高亮,声效,特效,动画等.

8
BPEL(Business Process Execution Language)用于异构环境的,基于Web的复杂环境业务流系统。

http://en.wikipedia.org/wiki/BPEL
http://searchwebservices.techtarget.com/sDefinition/0,,sid26_gci845110,00.html



作者 Re:最近工作的一些小tips集合 [Re:tier3]
tier3





发贴: 228
积分: 120
于 2005-08-23 10:39 user profilesend a private message to usersend email to tier3search all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
版主加分好及时。Smile
惭愧惭愧,最近对论坛贡献不多了。Smile



作者 Re:最近工作的一些小tips集合 [Re:tier3]
tier3





发贴: 228
积分: 120
于 2005-08-23 10:43 user profilesend a private message to usersend email to tier3search all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
以下是我在上家单位时做的一些小技巧集合。

1.
Since build 1090 AspectJ support in idea is disabled by default.
To enable it add :

-Didea.aspectj.support=enabled

VM option to your .bat/.sh/.lax/Info.plist file or whatever

2. how to change your box's Locale;

input_method/properties/General/Set default/

3.IDE中Debug DOS bat文件
My solution is that > Add the path of yourTestBat.bat in additional to the system path variable. >
Close and restart the IDE. > Compile and run/debug it right in your IDE.
Runtime.getRuntime().exec(your_DOS_command);
public class InfoProcessManager
{
static {
//前提是把运行命令所在的目录加到system path中,i.e.C:\http\htdocs\infospc\bin
System.loadLibrary("viadorNativePM");
}

public native static int getPID();
public native static void killProcess(int pid, int signal);
public native static void forceProcessIntoSingleProcessor();

4. SQL SERVER中大小写敏感设置, 用varbinary()可以实现,不过用collation好象不行。
SQL_Latin1_General_CP1_CS_AS
ALTER TABLE dbo.MM_PRIMARY
ALTER COLUMN Address varchar(15) COLLATE SQL_Latin1_General_CP1_CS_AS NULL

SELECT *
FROM ::fn_helpcollations()

http://66.102.11.104/search?q=cache:Lf5Jh5KQWxoJ:vyaskn.tripod.com/case_sensitive_search_in_sql_server.htm+sqlserver+sort+order&hl=zh-CN&ie=UTF-8
http://www.itworld.com/AppDev/136/ITW3856/
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/architec/8_ar_da_3zw3.asp

5. Vector.clone()方法只是Shallow clone, 不是deep clone, 如果需要实现deep clone,必须对vector内每个element都独自做
一次clone。
final Vector oldDSVec = new Vector();
Vector dsVec = getDatasourceVector();
for (int j = 0; j < dsVec.size(); j++) {
DataSourceElement ds = (DataSourceElement) dsVec.elementAt(j);
oldDSVec.add(ds.clone());

}
//End add by Jonathan.Fan
final Vector oldElementVec = new Vector();
Vector elementVec = sheet.getElements(target);
for (int j = 0; j < elementVec.size(); j++) {
ReportElement o = (ReportElement) elementVec.elementAt(j);
oldElementVec.add(o.clone());

}

以上代码有一个问题:
建议用super.clone()而不是直接new一个实例,super.clone()最后调用的是Native的object.clone(),速度比new一个实例快得多。
Cloneable接口是不包含任何方法的

immutable classes are an important concept in object oriented development. They are thread safe, make excellent Hashtable keys, and they don’t need to be cloned when passed as an argument to another method. They make life as a developer easier because you don’t have to write as much code to ensure stability and save you a great deal of frustrating debugging time down the road.

1Hashcodes for String objects are generated from the character arrays, so two Strings with the same series of characters will always have the same hash even if they are physically two separate objects.

public void setupHash(){
Hashtable ht = new Hashtable();
String key = "key1";
ht.put(key, new Vector());
key = "key2";
Vector vec = (Vector)ht.get("key1");
vec.addElement(new Integer(5));
}
以上方法不会出问题,如果把key的类型变为StringBuffer,将会在最后一行抛出NullPointerException.

跟Vector一样,StringBuffer也有它的最大容量,StringBuffer缺省的容量是16,如果append的值超过此容量,系统将拷贝所有的值,再创建一个新的StringBuffer对象

A final class will prevent another class from extending it.

A final method cannot be overridden in a subclass (presuming that the class itself is not final).

A final attribute will be treated as a constant that cannot be changed.

6. 让你的JDialog居中:
AboutDialog dialog = new AboutDialog(m_context, ((Frame)this),null,null);
dialog.pack();

// add by bruce for 235 issue on 6/11/2004 3:14PM
// set the dialog alignment center
Dimension dimension = dialog.getSize();
Dimension dimension1 = dialog.getToolkit().getScreenSize();
if(dimension1.width < dimension.width || dimension1.height < dimension.height) {
dimension.width = Math.min(dimension1.width, dimension.width);
dimension.height = Math.min(dimension1.height, dimension.height);
dialog.setSize(dimension);
}
dialog.setLocation((dimension1.width - dimension.width) / 2, (dimension1.height - dimension.height) / 2);
// add end
// the following code must be called after setLocation() method,
// otherwise setLocation does not take effect.
dialog.setVisible(true);

7.
如果在web能看到某一些gif图片,但是直接用IE打开使用这些图片的HTML却看不到,试试把这些gif改为jpg看看,
主要原因应该是这些gif太大了,在thumbnail模式下也看不到,只有用ACDSEE打开才看得到。

8.使用chr函数在Oracle中插入回车符:
insert into texttest values(6, chr(10)||chr(13)||'n');
使用char函数在MSSQL中插入回车符:
INSERT INTO [pubs].[dbo].[jobs]([job_desc], [min_lvl], [max_lvl])
VALUES(char(10)+char(13)+char(10)+char(13)+'888', 11, 77)

9.
apply pattern process: 1. analyze the real requirement from your own application; 2. learn the pattern carefully, understand its benefits and liabilities. 3. analyze how to apply the pattern into your own application, maybe not the same as the sample in the pattern, but customize it after mastering the pattern's spirit.

10.
禁止C$、D$一类的缺省共享
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\lanmanserver\parameters
AutoShareServer、REG_DWORD、0x0

禁止ADMIN$缺省共享
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\lanmanserver\parameters
AutoShareWks、REG_DWORD、0x0

限制IPC$缺省共享
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa

restrictanonymous REG_DWORD 0x0 缺省
0x1 匿名用户无法列举本机用户列表
0x2 匿名用户无法连接本机IPC$共享
说明:不建议使用2,否则可能会造成你的一些服务无法启动,如SQL Server

11.
数据抽取、转换和装载(Extract, Transform, Load) 负责将数据从业务系统或外部系统中获得,转换和处理成数据仓库需要的格式和形态,并在规定的时间装入到数据仓库中去。通常我们把这三个具体的步骤统称为ETL,在系统实现时一般采用数据抽取工具和应用编程实现,并拥有调度管理和控制功能。

12.
新的OUTER JOIN句法

ISO99标准把复杂的加号从Oracle outer join中拿出去,并使得outer join SQL更容易理解。

LEFT OUTER JOIN
在LEFT OUTER JOIN中,会返回所有左边表格中的行,甚至在被连接的表格中没有可配对的栏目的情况下也如此。在下边的例子中,返回了所有雇员的姓,甚至包括了那些没有分配到部门的雇员。

Oracle8i
select last_name, dept_id
from emp e, dept d
where e.department_id = d.department_id(+);

Oracle9i
select last_name, dept_id
from emp
LEFT OUTER JOIN Dept
ON e.dept_id = d.dept_id;

RIGHT OUTER JOIN
在RIGHT OUTER JOIN中返回的是表格中所有右边的行,甚至在被连接的表格中没有可配对的栏目的情况下也如此。在这个例子中,返回了所有部门的ID,包括那些没有一个雇员的的部门。
Oracle8i
select last_name, d.dept_id
from employees e, departments d
where e.department_id(+) = d.department_id;

Oracle9i
select last_name, d.dept_id
from employees e
RIGHT OUTER JOIN departments d
ON (e.department_id = d.department_id);

13. JNI 101.
java source --> .h source --> .c/.cpp source --> .dll(name from System.loadLibrary() in java source)

http://www.programfan.com/showarticle.asp?id=1660
http://www.pconline.com.cn/pcedu/empolder/gj/java/0408/428789.html

14. 用SavePoint实现事务处理。
Class.forName(driver).newInstance();
connection = DriverManager.getConnection(url,username,password);
DriverManager.setLogStream(System.out); // for debuging
connection.setAutoCommit(false);
//create a statement
stmt = connection.createStatement();
//execute a query
stmt.executeUpdate("insert into tickets values ('ivana', 'NY', 'BOSTON', '11-July-2002', '9:00 AM', 'Delta 782')");
stmt.executeUpdate("insert into tickets values ('ivana', 'BOSTON', 'CANCUN', '11-July-2002', '12:00 PM', 'Delta 819')");
txpoint = connection.setSavepoint("oneway"); // establish a save point

stmt.executeUpdate("insert into tickets values ('ivana', 'CANCUN', 'NY', '12-August-2002', '2:00 PM', 'Delta 820')");
stmt.executeUpdate("insert into tickets values ('ivana', 'NY', 'BOSTON', '12-August-2002', '6:00 PM', 'Delta 783')");

// for demo purposes in case there are no exceptions
if (forseoneway && (txpoint != null) )
connection.rollback(txpoint);

connection.commit();

setTransactionIsolation

15.
在CDATA的值内用]>]结尾可以把该属性之后的所有值都列为该属性的值内容
用c14n Canonicalization 可以解决这个问题,org.apache.xml.security

16. together eclipse 反向工程看类图
eclipse加together 6.2的plug-in以后,就有一个together的视图了。在那个视图中,
有一个uml的浏览方式,所有源码在这个方式下都可以自动找到相对就的类图。
(tec的类和类图是完全一一自动对应的,也就是,改动源码,类图自动改变,改动类图,源码也自动改变。)

有一点不太满意,好象不能在一个diagram里显示在一个目录下面所有文件的关系,包括子目录。

17. 在IDEA中用regex进行text replace
定义:
runReport\(defFile\, path\)\;
runReport\\(defFile\\, path\\)\\;\r\n assertSameFileContent\\(getExpectedPathByTargetPath\\(path\\), path\\)\\;
结果:
runReport(defFile, path);
-->
runReport(defFile, path);
assertSameFileContent(getExpectedPathByTargetPath(path), path);

18. 万一在IDEA中你的修改过的文件被SOS或VSS覆盖了,可以到D:\IntelliJ-IDEA-4.5\system\vcs\viadorbi_ipr.e6f62c1e
下面找找。

19. 在ant的javac task中加debug="true" debuglevel="lines,source" 如果加source是不是把源码也加进去了???只加lines如何?
http://www.jguru.com/faq/view.jsp?EID=1122360

<javac srcdir="${app.source.src}" destdir="${app.build.class}" debug="true"
debuglevel="lines,source" deprecation="off">

22.
交叉数据报表

有时候需要旋转结果以便在水平方向显示列,而在垂直方向显示行。这就是所谓的创建 PivotTable?、创建交叉数据报表或旋转数据。

假定有一个表 Pivot,其中每季度占一行。对 Pivot 的 SELECT 操作在垂直方向上列出这些季度:

Year Quarter Amount ---- ------- ------ 1990 1 1.1 1990 2 1.2 1990 3 1.3 1990 4 1.4 1991 1 2.1 1991 2 2.2 1991 3 2.3 1991 4 2.4

生成报表的表必须是这样的,其中每年占一行,每个季度的数值显示在一个单独的列中,如:
http://bbs.openlab.net.cn/ShowThread.aspx?PostID=368137
http://dw.isc.ucsb.edu/what_is_pivotrpt.html



作者 Re:最近工作的一些小tips集合 [Re:tier3]
littledeer1974

Garbage Collector

CJSDN高级会员


发贴: 1517
积分: 122
于 2005-08-23 14:19 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
做贡献,不分早晚
加分感谢



Surround yourself with people who are open to change


flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923