小编ham*_*ama的帖子

如何获取Servlet Context中的所有属性名称(嵌套与否),如果是映射或列表则迭代?

我试图获取一个维护不良的上下文的attributeNames,然后使用带有反射的那些名称.

这是一些粗略思想的伪代码.例如,我在上下文中有一个ArrayList和一个HashMap.

enum = getServletContext().getAttributeNames();
for (; enum.hasMoreElements(); ) {
    String name = (String)enum.nextElement();

    // Get the value of the attribute
    Object value = getServletContext().getAttribute(name);

    if (value instanceof HashMap){
      HashMap hmap = (HashMap) value;
      //iterate and print key value pair here
    }else if(value instanceof ArrayList){
      //do arraylist iterate here and print
    }
}
Run Code Online (Sandbox Code Playgroud)

java attributes loops servlets

7
推荐指数
1
解决办法
3万
查看次数

IE-8 iframe和flash对象忽略了z-index?

我有以下div,我正在尝试在my_flash前面制作iframe层.这是一个常见的问题,我已经阅读了所有可以找到的解决方案,但我仍然在IE8中遇到问题.顺便说一句,我正在使用SWFobject.

这是来源:

<script type="text/javascript">
swfobject.embedSWF("index.swf", "my_flash", "100%", "100%", "8.0.0");
swffit.fit("my_flash",900,650);
</script>

<div id="my_flash" style="z-index:1;"></div>

<div  style="border:none; overflow:hidden; width:50px; height:21px; z-index:9999; position: absolute; bottom: 5px; left: 110px;" >
<iframe src="http://www.facebook.com/plugins/like.php?blah.html" scrolling="no" frameborder="0" allowTransparency="true"  style="z-index:9998"/>
</div>
Run Code Online (Sandbox Code Playgroud)

flash iframe swfobject z-index internet-explorer-8

4
推荐指数
1
解决办法
1万
查看次数

将字符串值传递给动画Jquery函数时出现问题

嘿,我想知道这两个代码之间有什么区别?第一个工作但第二个不工作?

First >>
for (i=0; i<$sequencingArray.length; i++){
...
$($sequencingArray[i]).delay(i*100).animate({'margin-left':$masterWidth});
...
}

Second >>
$propToAnimate = 'margin-left';
for (i=0; i<$sequencingArray.length; i++){
...
$($sequencingArray[i]).delay(i*100).animate({$propToAnimate:$masterWidth});
...
}
Run Code Online (Sandbox Code Playgroud)

string variables jquery assign jquery-animate

2
推荐指数
1
解决办法
1123
查看次数

如何在没有链接的情况下调用函数链中的任何函数?

对不起,如果我的问题不够明确.我会把我的代码放在这里......

var chain = {
    'fn_1' : {
             //fn_1 code here
             chain.fn_2();},
    'fn_2' : {
             //fn_2 code here
             chain.fn_3();}

...and so on
}
Run Code Online (Sandbox Code Playgroud)

让我们说如果我调用chain.fn_1(),有没有办法可以在不调用chain.fn_2()的情况下执行此操作?

我现在能想到的是一面旗帜,但每个功能可能会有很多过剩的旗帜.你们有什么想法吗?

javascript function object literals chain

0
推荐指数
1
解决办法
1426
查看次数

有没有办法重构这个javascript/jquery?

switch (options.effect) {

case 'h-blinds-fadein':
    $('.child').each(function(i) {
        $(this).stop().css({
            opacity: 0
        }).delay(100 * i).animate({
            'opacity': 1
        }, {
            duration: options.speed,
            complete: (i !== r * c - 1) ||
            function() {
                $(this).parent().replaceWith(prev);
                options.cp.bind('click', {
                    effect: options.effect
                }, options.ch);
            }
        });
    });

    break;

case 'h-blinds-fadein-reverse':
    $('.child').each(function(i) {
        $(this).stop().css({
            opacity: 0
        }).delay(100 * (r * c - i)).animate({
            'opacity': 1
        }, {
            duration: options.speed,
            complete: (i !== 0) ||
            function() {
                $(this).parent().replaceWith(prev);
                options.cp.bind('click', {
                    effect: options.effect
                }, options.ch);
            }
        });
    });

    break;

    ....more …
Run Code Online (Sandbox Code Playgroud)

javascript jquery refactoring case switch-statement

0
推荐指数
1
解决办法
190
查看次数