JAVA & XML & JAVASCRIPT & AJAX & CSS

Web 2.0 技术储备............

  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  77 随笔 :: 17 文章 :: 116 评论 :: 0 Trackbacks

我的评论

辛苦了,中秋快乐!
2.7. HttpClient proxy configuration
Even though HttpClient is aware of complex routing scemes and proxy chaining, it supports only simple direct or one hop proxy connections out of the box.

The simplest way to tell HttpClient to connect to the target host via a proxy is by setting the default proxy parameter:

DefaultHttpClient httpclient = new DefaultHttpClient();

HttpHost proxy = new HttpHost("someproxy", 8080);
httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);

One can also instruct HttpClient to use the standard JRE proxy selector to obtain proxy information:

DefaultHttpClient httpclient = new DefaultHttpClient();

ProxySelectorRoutePlanner routePlanner = new ProxySelectorRoutePlanner(
httpclient.getConnectionManager().getSchemeRegistry(),
ProxySelector.getDefault());
httpclient.setRoutePlanner(routePlanner);

Alternatively, one can provide a custom RoutePlanner implementation in order to have a complete control over the process of HTTP route computation:

DefaultHttpClient httpclient = new DefaultHttpClient();
httpclient.setRoutePlanner(new HttpRoutePlanner() {

public HttpRoute determineRoute(
HttpHost target,
HttpRequest request,
HttpContext context) throws HttpException {
return new HttpRoute(target, null, new HttpHost("someproxy", 8080),
"https".equalsIgnoreCase(target.getSchemeName()));
}

});

@麦胖
呵呵,谢谢赞赏。
请把你修改后的代码发到的邮箱 wellse@qq.com 我看下。
q@ice
请学习下Javascript的闭包特性,你就明白啦!
@余如水
给我找个工作嘛~~
re: 我的书出版了 Web 2.0 技术资源 2010-04-28 10:22  
恭喜,恭喜
谢谢楼上的兄弟! 对头................. 的确存在那样的问题。
没考虑周全。
re: 源码分析:HashMap Web 2.0 技术资源 2008-08-27 11:37  
#########################################
void transfer(Entry[] newTable) {
   Entry[] src = table;
   int newCapacity = newTable.length;
   for (int j = 0; j < src.length; j++) {
     Entry e = src[j];
     if (e != null) {
       src[j] = null;
       do {
          Entry next = e.next;
          int i = indexFor(e.hash, newCapacity);
          e.next = newTable[i];
          newTable[i] = e;
          e = next;
       } while (e != null);
     }
   }
}
遍历原来的数组,如果该Entry不是null的话,说明有映射,然后遍历这个链表,把所有的映射插入到新的数组中,注意这里要从新计算索引位置。
#########################################

Entry next = e.next;
int i = indexFor(e.hash, newCapacity);
e.next = newTable[i]; ?????????
newTable[i] = e; ?????????

为什么 e.next 要指向自己呢?


@sly
报什么错啊........ 不得哦!
@js

设计这个Map 主要是为了填补 Javascript 中没有Map工具的不足。

你觉得你用Array 来代替 Map 那样你写的Javascript 会清晰明了吗?

那在Java里面何必需要HashSet, 直接用HashMap也能实现~

关键是让自己编码更清晰.... 数据类型更明了。
re: Struts+Hibernate实现shopcart Web 2.0 技术资源 2007-05-25 20:54  
做个服务层吧~
把业务逻辑集中到 Service

re: Struts+Hibernate实现shopcart Web 2.0 技术资源 2007-05-25 10:21  
你应该对 collection 框架还不够熟悉~ 加强下就OK了~
re: Struts+Hibernate实现shopcart Web 2.0 技术资源 2007-05-25 09:59  
看错意图了~ 这样就OK了~
return new ArrayList( hs.values() );
re: Struts+Hibernate实现shopcart Web 2.0 技术资源 2007-05-25 09:31  
头都大了~~
// 将hashmap中value转到list中
public static List getList(HashMap hs) {
List list = new ArrayList();
Iterator itr = hs.keySet().iterator();
while (itr.hasNext()) {
list.add(hs.get(itr.next()));
}
return list;
}

return new ArrayList( hs.keySet() );
就可以了撒,多麻烦的。
re: 关于java class loader的理解笔记 Web 2.0 技术资源 2007-04-11 14:27  
好玩!!!!!!!!
re: 初始化有序常量的一点小技巧 Web 2.0 技术资源 2007-04-11 11:16  
嘿嘿!~
莫名其妙.......... 不过还是辛苦了.
re: xjl:关于String类的split方法 Web 2.0 技术资源 2007-01-25 12:06  
虽然使用正则表达式能很好的进行字符串的解析、提取、替换,但是对于一些简单的应用,使用 String 类提供的一些方法就可以很好的完成,最突出的就是 split 方法。

和后面说的矛盾了..........
re: [原创]prototype对于标签定位的一些BUG Web 2.0 技术资源 2006-12-10 20:50  
Object is positioned relative to parent element's position—or to the body object if its parent element is not positioned—using the top and left properties.

查文档才是王道!~
re: 欢迎加入成都java俱乐部 Web 2.0 技术资源 2006-11-30 20:02  
BLOG ID: fantasy

QQ:8635335

期待加入ing .......

re: JS实现文本框输入提供选择框的提示功能-1 Web 2.0 技术资源 2006-11-23 22:52  
Javascript 也应该面向对象呀~ 老大..........
re: 值得重视的Comparable接口 Web 2.0 技术资源 2006-11-03 21:41  
策略模式.... 鉴定完毕......
re: 空(标识)接口的重要性 Web 2.0 技术资源 2006-10-29 14:36  
经典~! 很不错~~~

不幸的是..... 我还贴着菜鸟的标签.........
re: [经典]在Mozilla中使用XML和JavaScript....... Web 2.0 技术资源 2006-10-26 23:59  
其实我已经给你提供API了....... 可是你把他给改了....... 最可怕的是改错了

if (moz)
{
xmlDoc = document.implementation.createDocument("", "", null);
/*这里错大了!
readXML(xmlDoc);
*/
/*正确方式*/
xmlDoc.load( file );
xmlDoc.onload = function(){ readXML(xmlDoc); }
}


/********************* 代码 ***********************/
<script language="javascript">
function importXML(file)
{
var xmlDoc=null;
var moz = (typeof document.implementation != 'undefined') && (typeof document.implementation.createDocument !='undefined');
var ie = (typeof window.ActiveXObject != 'undefined');
if (moz)
{
xmlDoc = document.implementation.createDocument("", "", null);
/*这里错大了!
readXML(xmlDoc);
*/
/*正确方式*/
xmlDoc.load( file );
xmlDoc.onload = function(){ readXML(xmlDoc); }
}
else if (ie)
{
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = false;
xmlDoc.onreadystatechange = function()
{
if(xmlDoc.readyState == 4) readXML(xmlDoc);
}
xmlDoc.load(file);
}
}

function readXML( xmlDocObj )
{
var company = xmlDocObj.getElementsByTagName("company");
window.alert(company.length);
}

function doXML()
{
importXML("11.xml");
}
</script>
没实现 Visitor 和 Visitable 接口的 Visitor 模式.......

哈哈........ 感觉已经变成简单的策略模式了........

实在不好意思......... 有点变味了.........
re: 您不得不关注的成长群体 Web 2.0 技术资源 2006-10-25 22:57  
"有志于实现四个现代化的青壮年"..............

哈哈哈!!!!!!!!!!

很有趣啊~ 可惜偶老了.............
re: JavaScript For Beginners(转载) Web 2.0 技术资源 2006-10-25 20:05  
俺是中国人........ 看不懂E文..........
不错! 总算看到另外一个版本的 外观模式介绍了...........

感谢ing
re: [经典]在Mozilla中使用XML和JavaScript....... Web 2.0 技术资源 2006-10-25 19:43  
估计是你加载 XML 的方式没对。

请参考:
function loadXML(file)
{
var xml = null;
var ie = (typeof window.ActiveXObject != 'undefined');
var moz = (typeof document.implementation != 'undefined') && (typeof document.implementation.createDocument != 'undefined');
if (moz)
{
xml = document.implementation.createDocument("", "", null)
xml.load(file);
xml.onload = function ()
{
viewData(xml);
}
}
else if (ie)
{
xml = new ActiveXObject("Microsoft.XMLDOM");
xml.async = false;
xml.load(file);
if(xml.readyState == 4)
{
viewData(xml);
}
}
}

参考地址 : http://bbs1.softhouse.com.cn/index.htm?url=/forum/help/user/index.jsp
修正了一个严重的BUG .

情况1
var array = new Array();
array.push("A"); array.length = 1

情况2 (想当然的为初始化长度,以为那样效率可以高那么一点点........)
var array = new Array( 3 );
array.push("A"); array.length = 4

区别大呢............. 不像JAVA里面....

他爷爷的~~!


re: 在java中使用循环定义会出现哪些问题? Web 2.0 技术资源 2006-10-19 21:13  
谁这样写代码~ 就枪毙他!
该 Pager 能使用于任何WEB容器。

关键是怎么使用他。
果然够深度! 支持!! 顶!
re: 按字节截取含双字节的字符串! Web 2.0 技术资源 2006-10-13 21:12  
效率太低了...........

给个简单的处理方式吧~~~

public static String getShorterString( String input , int bytes )
{
try
{
byte[] array = input.getBytes("GBK");
if( bytes >= array.length ) return input;
String result = new String(array , 0 , bytes ,"GBK");
return result.length() > 0 ? result : new String(array , 0 , bytes - 1 ,"GBK");
}
catch (UnsupportedEncodingException e)
{
return input;
}
}
re: 芒果软件实验室 诚揽人才 Web 2.0 技术资源 2006-09-11 17:46  
拼命打撒~~~

打不过就撤退~~~~~~~~

没的撤的地方了~~~ 就同志们就顶住!
@谭立平

谢谢 楼上的兄弟提出的BUG ~ 不过我自己测还没测出这个问题......

再次去参考了文档 :
/***********************************************/
delete 运算符
从对象中删除一个属性,或从数组中删除一个元素。
delete expression
expression 参数是一个有效的 JScript 表达式,通常是一个属性名或数组元素。
说明
如果 expression 的结果是一个对象,且在 expression 中指定的属性存在,而该对象又不允许它被删除,则返回 false。
在所有其他情况下,返回 true。
/***********************************************/
在删除元素的时候增加了~ this.containsKey(key) 的条件限制。
增加了 clear 方法。
re: 别忘了转义\\ Web 2.0 技术资源 2006-05-30 15:21  
啊........ 就怎么点啊...... 晕.....
@dennis

谢谢支持!

这个是在我上次写的HashMap上完全改进的~~~

谢谢 bbs.51js.com 上的朋友提出宝贵的意见。
re: 防止任意形式的重复提交 Web 2.0 技术资源 2006-05-06 17:52  
Struts 的 Token 机制可以解决这个问题。

如果没用Struts 怎么办哇 .................. 郁闷。
/** key允许空值但hashcode方法却没有对其进行空值检查? **/

这个的确是问题............. 但是我不想考虑太多的因素进去......
我觉得那些应该由用户自己来检查.....

否则会让正个代码变得很郁闷........... 郁闷拉。 55555555555
/**
resize要个_this参数干嘛用?
**/

是为了解决 用 var 定义的方法不能调用 this 方法... [私有不能访问公有方法]

所以得显示的传递一个 this 对象。
/**
if(++code > length){
code = 0;
}
干什么用?hashcode居然和length绑在一起,感觉很怪。。。
**/

因为如果当前位置发生冲突.......... 则向后查找.. 如果 > length 则 置0 。
re: 具有臭味的代码 Web 2.0 技术资源 2006-03-24 09:34  
晕~~~ 这臭味也太多拉......... 55555555555