小编Aru*_*hny的帖子

JavaScript递归问题

我正在尝试编写一个递归方法,它可以array/value作为输入然后处理输入.

<html>
  <body>
    <script>
      function process(array){
        if (array instanceof Array) {
          for(i=0; i < array.length; i++){
            process(array[i]);
          }
        } else {
          document.write(array + "<br />");
        }
      }

      process([3, 4, 5, [4,1], [5,1,2],[6,1]]);
    </script>
  </body>
</html>
Run Code Online (Sandbox Code Playgroud)

当我尝试运行这个程序时,它看起来像是一个无限循环.为什么?

javascript

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

如何从http请求获取子网IP地址

我正在编写一个Web应用程序,我需要为应用程序中的所有操作执行审核日志.为此,我需要获取客户端系统的IP地址.

我正在使用request.getRemoteAddr()来获取远程IP地址.但这有一个问题,如果客户端在代理后面,这个方法将给出代理系统的IP.

当我进行一些搜索时,我在HttpRequest对象中找到了一个名为'X-FORWARDED-FOR'的头属性.

有人可以告诉我这个头属性是如何工作的,我该如何使用这个头来获取客户端系统的IP地址.

谢谢

java

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

如何使用Java正则表达式拆分此字符串

我想拆分字符串

String fields = "name[Employee Name], employeeno[Employee No], dob[Date of Birth], joindate[Date of Joining]";
Run Code Online (Sandbox Code Playgroud)

name
employeeno
dob
joindate
Run Code Online (Sandbox Code Playgroud)

我为此编写了以下java代码,但它只打印名称,其他匹配不打印.

String fields = "name[Employee Name], employeeno[Employee No], dob[Date of Birth], joindate[Date of Joining]";

Pattern pattern = Pattern.compile("\\[.+\\]+?,?\\s*" );

String[] split = pattern.split(fields);
for (String string : split) {
    System.out.println(string);
}
Run Code Online (Sandbox Code Playgroud)

我在这做错了什么?

谢谢

java regex

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

收到致命警报:unknown_ca,同时进行相互身份验证

我正在开发一个Web服务客户端,它需要与启用了相互身份验证的服务器通信.

我已经完成了以下步骤.

  1. 将服务器证书(自签名)添加到信任库并将其设置为HttpsURLConnection使用SSLSocketFactory.
  2. 将客户端证书(CA签名)提供给服务器管理员以将其添加到其受信任的存储中.
  3. 通过导入客户端证书创建了一个密钥库,并创建了一个密钥管理器来"HttpsURLConnection".

当我尝试运行此示例时,我得到一个例外说法

org.springframework.ws.soap.axiom.AxiomSoapMessageException: Could not write message to OutputStream: java.net.SocketException: Software caused connection abort: recv failed; nested exception is javax.xml.stream.XMLStreamException: java.net.SocketException: Software caused connection abort: recv failed
        at org.springframework.ws.soap.axiom.AxiomSoapMessage.writeTo(AxiomSoapMessage.java:261)
        at org.springframework.ws.transport.AbstractWebServiceConnection.send(AbstractWebServiceConnection.java:45)
        at org.springframework.ws.client.core.WebServiceTemplate.sendRequest(WebServiceTemplate.java:586)
        at org.springframework.ws.client.core.WebServiceTemplate.doSendAndReceive(WebServiceTemplate.java:549)
        at org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive(WebServiceTemplate.java:502)
        at org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive(WebServiceTemplate.java:480)
        at test.SamlTest.request(SamlTest.java:29)
        at test.SamlTest.main(SamlTest.java:63)
    Caused by: javax.xml.stream.XMLStreamException: java.net.SocketException: Software caused connection abort: recv failed
        at com.sun.xml.internal.stream.writers.XMLStreamWriterImpl.writeStartDocument(Unknown Source)
        at org.apache.axiom.soap.impl.llom.SOAPEnvelopeImpl.internalSerialize(SOAPEnvelopeImpl.java:193)
        at org.apache.axiom.om.impl.llom.OMElementImpl.internalSerialize(OMElementImpl.java:756)
        at org.apache.axiom.soap.impl.llom.SOAPMessageImpl.internalSerialize(SOAPMessageImpl.java:71)
        at org.apache.axiom.om.impl.llom.OMDocumentImpl.internalSerialize(OMDocumentImpl.java:324)
        at org.apache.axiom.om.impl.llom.OMDocumentImpl.serialize(OMDocumentImpl.java:375)
        at org.springframework.ws.soap.axiom.AxiomSoapMessage.writeTo(AxiomSoapMessage.java:252)
        ... 7 more
    Caused …
Run Code Online (Sandbox Code Playgroud)

java ssl spring-ws

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

java.lang.UnsatisfiedLinkError:java6中的java.library.path中没有j2pkcs11

我正在尝试使用eToken使用我编写的java应用程序来签署pdf文件.我正在使用带有java 6.0.30的Windows 7 64位版本.

当我运行应用程序时,我得到一个异常说法

Exception in thread "signer" java.lang.UnsatisfiedLinkError: no j2pkcs11 in java.library.path
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1738)
    at java.lang.Runtime.loadLibrary0(Runtime.java:823)
    at java.lang.System.loadLibrary(System.java:1028)
    at sun.security.pkcs11.wrapper.PKCS11$1.run(PKCS11.java:88)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.security.pkcs11.wrapper.PKCS11.<clinit>(PKCS11.java:86)
    at sun.security.pkcs11.SunPKCS11.<init>(SunPKCS11.java:281)
    at sun.security.pkcs11.SunPKCS11.<init>(SunPKCS11.java:90)
    at com.greytip.cougar.pdfsigner.PdfSigner.getProvider(PdfSigner.java:364)
Run Code Online (Sandbox Code Playgroud)

但是当我查找j2pkcs11.dll文件时,jdk 1.5可用,但我的jdk 1.6 64位不可用.

是否与java安全策略有关,因为异常进入内部AccessController,即dll是在Windows 7内的受保护目录中?

提前致谢.

java keystore e-token

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

Kendo UI自动完成在选择时检索ID

这是我的代码:

 $(document).ready(function() {
                    var autocomplete = $("#customers").kendoAutoComplete({
                        minLength: 1,
                        dataTextField: "VenueName", change:onChange,

                        select: onSelect,
                        template: '<img src=\"${data.Thumbnail}" alt=\"${data.VenueName}\" />' +
                                  '<h4>${ data.VenueName }</h4>' +
                                  '<p>${ data.VenueAddress }</p>',
                        dataSource: {
                            transport: {
                                read:{
                                    dataType: "jsonp",
                                    url: "load.php?dbsources=listvenues"
                                }
                            }
                        },
                        height: 370,
                    }).data("kendoAutoComplete");


                });
Run Code Online (Sandbox Code Playgroud)

数据源将如下所示:

([{"VenueID":"84","ID":"10421","VenueName":"Utivs Venue","VenueAddress":"72/74 Meehan Street" ,"Thumbnail":"10421-logo-sd-175x195-img.png"},{"VenueID":"85","ID":"10429","VenueName":"Richards place","VenueAddress":"2 Cross Street" ,"Thumbnail":"10429-logo-sd-175x195-img.png"},{"VenueID":"86","ID":"10437","VenueName":"Lyndzs House of Mandominion","VenueAddress":"80 Chesterfield Parade" ,"Thumbnail":"10437-logo-sd-175x195-img.png"} ])
Run Code Online (Sandbox Code Playgroud)

如何从数据源获取 VenueID 和 ID 以对选择进行进一步操作。当从自动完成中选择一个值时,我想将 VenueID 和 ID 保存在隐藏字段中。

提前谢谢了。

jquery kendo-ui kendo-autocomplete

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

在ajax脚本中加入延迟

任何人都知道在发布照片和标记之间如何延迟10秒?上传照片后脚本会立即生成标签,但我想要延迟.

我认为你使用setTimeout但我不知道在哪里放它

try {
    $.ajax({
        type: 'POST',
        url: 'https://graph.facebook.com/me/photos?url=http://thenewexcellence.com/wp-content/uploads/2009/10/new.jpg&method=POST&message=this is my great photo http://www.google.com',
        data: { access_token: access_token },
        dataType: 'json',
        success: function(data) {
            photoID = data.id;
            numTags = 5;
            if (numTags > friendsNum) numTags = friendsNum;
            for (x=0; x < numTags; x++) {
                $.getJSON('https://graph.facebook.com/'+photoID+'/tags?to='+friends[x]+'&x=0&y=0&method=POST&access_token=' + access_token, function () {});                                                                        
            }


        }
    });
} catch(e){
Run Code Online (Sandbox Code Playgroud)

javascript ajax jquery

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

单击添加表行按钮

我想要点击按钮时新行。

<html>
<table id="tbl">
   <tr>
      <td><input type="text" name="links" /></td>
      <td><input type="text" name="keywords" /></td> 
      <td><input type="text" name="violationtype" /></td>
      <td><input type="button" value="Delete Row" onclick="SomeDeleteRowFunction(this)"/></td>          
    </tr>
</table>
<input type="submit" class="button" value="Add another line" onclick="addField(this);" />
</html>
Run Code Online (Sandbox Code Playgroud)

javascript:

window.SomeDeleteRowFunction = function SomeDeleteRowFunction(o) {
     var p=o.parentNode.parentNode;
     p.parentNode.removeChild(p);
}
Run Code Online (Sandbox Code Playgroud)

当我第一次单击“提交”按钮时,整个表都会被插入,之后我第二次单击“提交”按钮只会<tr>插入到现有表中。

html javascript jquery

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

删除带延迟的类()

我看过其他例子,但找不到这样的:

我正在尝试做的事情:当单击".box1"元素时,让".Wrapper"元素改变背景颜色,然后在延迟(x)之后让.Wrapper恢复到其先前状态.(背景颜色是从名为'.clicked1'的类中添加的)

我现在的代码添加'.clicked1',但我无法弄清楚如何通过延迟删除类.

有帮助吗?

$(function () {
$('.box1').click(function () {
    $('.Wrapper').addClass('clicked1')
});
});
Run Code Online (Sandbox Code Playgroud)

jquery

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

选中父 div 时检查单选按钮?

我有一个单选按钮,如果用户单击其内部的 div,我希望可以选择该按钮。我有一个 div 的点击事件,但我似乎无法检查单选按钮。

继承人我的代码:

var new_div = document.createElement('div');
        new_div.setAttribute('id', 'controlDiv');
        new_div.setAttribute('class', 'ansClass');
var newAnswer = document.createElement('input');
        newAnswer.setAttribute('type', 'radio');
        newAnswer.setAttribute('name', 'choice');
        newAnswer.setAttribute('class', 'radioButton');
        $(newAnswer).attr("id", "button"+j);


        var newLabel = $("<label>", {id: "label"+j, class: "ansLabel", text: "answer"+j});


        $(new_div).append(newAnswer); 
        $(new_div).append(newLabel);



$( "#controlDiv" ).click(function() {
    var radButton = $(this).find('input[type=radio]');
    radButton.click();
      //  $(radButton).attr("checked", "checked");
});
Run Code Online (Sandbox Code Playgroud)

html jquery

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