小编Abd*_*ull的帖子

Facebook应用程序:允许单个Facebook应用程序在任意专用网络地址上运行

我有一个发展服务器(Java Servlet容器)上运行我的电脑上我的私有网络中(IP范围192.168.0.0192.168.255.255).此开发服务器执行我的集成测试环境.此测试环境具有自己的Facebook App ID.让服务器在该192.168.x.y范围内运行允许我的同事测试网站,使用他们的Facebook帐户登录我的本地网站等.

https://developers.facebook.com - >在Facebook应用程序设置 - >位于"基本设置" - >"网站登录Facebook"字段中,我已设置http://192.168.2.106:8080,因为这是地址 - 端口组合,我的开发服务器绑定到.

由于DHCP,我的电脑现在有一个稍微不同的IP地址,即192.168.2.109.每当我启动我的服务器,然后尝试做任何与Facebook-API相关的事情(例如Facebook登录)时,我从Facebook收到以下错误消息

{
   "error": {
      "message": "Invalid redirect_uri: Given URL is not allowed by the Application configuration.",
      "type": "OAuthException",
      "code": 191
   }
}
Run Code Online (Sandbox Code Playgroud)

有没有办法让Facebook应用程序允许"一系列带有Facebook登录的IP地址网站"?您能提出哪些其他解决方案?

我的同事也可以使用自己的专用网络地址在自己的机器上启动开发服务器.因此,相同的Facebook App ID应该在具有不同IP地址的不同机器上工作,并且仍然可以被专用网络内的每个人访问.

请注意,将"使用Facebook登录的网站"设置为localhost使开发服务器仅对其运行的同一台计算机可用.不幸的是,这会阻止同事访问此开发服务器实例.

更新

提起错误:https://developers.facebook.com/bugs/606277079382609

testing facebook

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

ElementNSImpl to String

我有一个调用Web服务的客户端,我正在收回一个ElementNSImpl对象.是否可以将此对象转换为String?

对于一个org.w3c.dom.Document对象,我使用过这样的代码:

protected static String documentToString(final Document doc) {
        // outputs a DOM structure to plain String

        try {
            StringWriter sw = new StringWriter();
            TransformerFactory tf = TransformerFactory.newInstance();
            Transformer transformer = tf.newTransformer();
            transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no");
            transformer.setOutputProperty(OutputKeys.METHOD, "xml");
            transformer.setOutputProperty(OutputKeys.INDENT, "yes");
            transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");

            transformer.transform(new DOMSource(doc), new StreamResult(sw));
            return sw.toString();
        } catch (Exception ex) {
            throw new RuntimeException("Error converting to String", ex);
        }
    }
Run Code Online (Sandbox Code Playgroud)

java xml web-services xerces

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

从Ember Handlebars模板中获取Ember控制器的函数属性

在Ember Handlebars模板中,可以使用以下方法访问控制器(基于字符串/布尔/数字)属性

  • {{someProperty}}
  • <someHtmlTag {{bindAttr someHtmlTagAttribute="someProperty" />

结构体.

这似乎不适用于基于功能的控制器属性.

以下作品

//Handlebars
<script type="text/x-handlebars" id="index">
    Some property: {{someProperty}}<br/>
</script>   

//Javascript
App.IndexController = Ember.ObjectController.extend({
    someProperty: "yolo",
});
Run Code Online (Sandbox Code Playgroud)

以下不起作用

//Handlebars
<script type="text/x-handlebars" id="index">
    Some property: {{someProperty}}<br/>
</script>   

//Javascript
App.IndexController = Ember.ObjectController.extend({
    someProperty: function() {
        return "yolo"; },
});
Run Code Online (Sandbox Code Playgroud)

这是一个jsFiddle


使用该方法可以{{bindAttr ...}}深入了解问题:

Uncaught Error: assertion failed: Attributes must be numbers, strings or booleans, not function ()  ...{
Run Code Online (Sandbox Code Playgroud)

如何从Handlebars模板中访问基于功能的Ember控制器属性?

handlebars.js ember.js

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

Spring Data JPA和MySQL:如何在多线程环境中避免"重复输入"错误?

我的Web应用程序的数据库基础结构是这样分层的:

  1. Spring Data JPA
  2. JPA
  3. 过冬
  4. C3P0池
  5. MySQL的

有些事务需要相当长的时间,有时一分钟用于一个大事务(目的是将数据缓存到数据库中):从用户到我的Web服务器的HTTP请求可能会开始此事务.然后,我的Web服务器可以向另一个远程第三方服务器查询丢失的数据.收集完所有数据后,事务就会完成,所有收集的数据都将写入数据库.

在这个长时间运行的事务中,用户可能会重新加载我的网站.这导致在单独的线程中为相同的数据开始另一个事务.由于此事务的目的是缓存,因此此操作本质上是幂等的,我不介意进行两次相同的计算.但在这些情况下,我的Web应用程序偶尔会遇到以下错误.

20:12:46.392 container [Thread-24] WARN  o.h.e.jdbc.spi.SqlExceptionHelper - SQL Error: 1062, SQLState: 23000
20:12:46.392 container [Thread-24] ERROR o.h.e.jdbc.spi.SqlExceptionHelper - Duplicate entry '146845042025054' for key 'PRIMARY'
20:12:46.602 container [Thread-24] INFO  o.h.e.j.b.internal.AbstractBatchImpl - HHH000010: On release of batch it still contained JDBC statements
Exception in thread "Thread-24" org.springframework.dao.DataIntegrityViolationException: Duplicate entry '146845042025054' for key 'PRIMARY'; SQL [n/a]; constraint [null]; nested exception is org.hibernate.exception.ConstraintViolationException: Duplicate entry '146845042025054' for key 'PRIMARY'
    at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:643)
    at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:104) …
Run Code Online (Sandbox Code Playgroud)

mysql hibernate jpa c3p0 spring-data-jpa

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

Bootstrap 3.1.0:加贴太长时间

我正在使用Bootstrap 3.1.0.当"视词"对于视口变得太长时,它会被切断,从不显示底部项目.

是否有可能让Bootstrap的词缀表现为用户仍然可以从上到下滚动整个词缀?

问题的例子:

<div class="container">
    <div class="row">

        <div class="col-md-3">
            <div class="list-group" id="sidebar">
                <a href="#" class="list-group-item">Long</a>
                <a href="#" class="list-group-item">list</a>
                <a href="#" class="list-group-item">with</a>
                <a href="#" class="list-group-item">many</a>
                <a href="#" class="list-group-item">entries</a>
                ...
                <a href="#" class="list-group-item">29. Last</a>
            </div>
        </div>

        <div class="col-md-9">
          ... regular content    
        </div>

    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

我希望我的jsFiddle能够解释这个问题.

javascript jquery twitter-bootstrap twitter-bootstrap-3

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

如何使用jquery添加onsubmit到表单

我想添加以下内容:

onsubmit="return processForm(this);
Run Code Online (Sandbox Code Playgroud)

到这个形式的id

<form id="formbuilder" name="featured_homes" method="post" action="fb/feedback.php">
Run Code Online (Sandbox Code Playgroud)

使用jquery,以便最终结果如下:

<form id="formbuilder" name="featured_homes" method="post" action="fb/feedback.php" onsubmit="return processForm(this);">
Run Code Online (Sandbox Code Playgroud)

这是我的尝试:

$('#formbuilder').onsubmit('return processForm(this);');
Run Code Online (Sandbox Code Playgroud)

这不行,有什么想法调整?

jquery

5
推荐指数
2
解决办法
7556
查看次数

可选的子捕获组

我正在与以下形式的数据工作(四个例子给出的,每个分离的由一个新行):

some publication, issue no. 3
another publication, issue no. 23
yet another publication
here is another publication
Run Code Online (Sandbox Code Playgroud)

我需要提取的出版物名称和 - 的情况下,它的存在 - 的发行数量。这必须用正则表达式来完成。

因此,鉴于上述数据,我正在寻找以下结果:

some publication            3
another publication         23
yet another publication     <null>
here is another publication <null>
Run Code Online (Sandbox Code Playgroud)

下面的模式只适用于具有数据, issue no. xyz部分:

    String underTest = "some publication, issue no. 3";

    String pattern = "(.*?), issue no. (\\d+)";
    Matcher matcher = Pattern.compile(pattern).matcher(underTest);

    boolean found = matcher.find();
    if (found) {
        log.info("something found");
        String group1 = matcher.group(1);
        log.info("group1: {}", group1); …
Run Code Online (Sandbox Code Playgroud)

java regex

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

Spring expression languague - 确定是否定义了servletContext变量

在spring上下文xml文件中,我使用spring EL表达式根据servletContext预定义变量是否为null来加载属性文件.下面是Spel表达式(为便于阅读而格式化):

#{
  systemProperties['my.properties.dir'] != null ?
    'file:' + systemProperties['my.properties.dir'] + '/' :
    (servletContext != null ? 
      'file:/apps/mydir' + servletContext.getContextPath() + '/' :
      'classpath:')
}my.properties
Run Code Online (Sandbox Code Playgroud)

当我在Web应用程序中运行时,一切都很好.但是,当我在独立应用程序中运行时(意味着未定义servletContext预定义变量),我收到以下错误:

Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 109): Field or property 'servletContext' cannot be found on object of type 'org.springframework.beans.factory.config.BeanExpressionContext'
Run Code Online (Sandbox Code Playgroud)

有没有办法确定servletContext是否存在?或者某些方法在未定义时避免异常?

java spring spring-el

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

如何使用JAXB参考实现将JAXB对象序列化为JSON?

我正在处理的项目使用JAXB参考实现,即类来自com.sun.xml.bind.v2.*包.

我有一节课User:

package com.example;

import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name = "user")
public class User {
    private String email;
    private String password;

    public User() {
    }

    public User(String email, String password) {
        this.email = email;
        this.password = password;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

}
Run Code Online (Sandbox Code Playgroud)

我想使用JAXB marshaller来获取User对象的JSON表示:

@Test …
Run Code Online (Sandbox Code Playgroud)

json jaxb

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

将java.time.temporal.Temporal转换为java.util.Date

如何将java.time.temporal.Temporal实例转换为java.util.Date实例?

java.time.temporal.Temporal someTemporal = Instant.now();
java.util.Date some Temporal = x(someTemporal);
Run Code Online (Sandbox Code Playgroud)

我已经看过Oracle的遗留时间跟踪文档,但找不到合适的解决方案.

java java-8 java-time

4
推荐指数
2
解决办法
7118
查看次数