小编sro*_*oes的帖子

file_get_contents('php:// input')返回带有PUT请求的空字符串

在将我们的一个网站从带有Apache的Linux移动到带有通过FastCGI运行PHP 5.6的IIS(8.5)的Windows之后,我们遇到了file_get_contents('php://input')为PUT请求返回空字符串的问题.

我创建了以下测试:

<?php
if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && 
    strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
    die(file_get_contents('php://input'));
}
?>
<!DOCTYPE html>
<html>
<head>
    <script src="//code.jquery.com/jquery-2.1.3.min.js"></script>
</head>
<body>
    <h2>POST:</h2>
    <div id="post"></div>

    <h2>PUT:</h2>
    <div id="put"></div>
    <script>
        $.ajax({
            url: '?',
            data: 'Working',
            type: 'POST'
        }).then(function(response) {
            $('#post').html(response || 'Not working');
        });

        $.ajax({
            url: '?',
            data: 'Working',
            type: 'PUT'
        }).then(function(response) {
            $('#put').html(response || 'Not working');
        });
    </script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

结果如下:

POST:

工作

放:

不工作

可能是什么导致了这个?

php fastcgi iis-8.5

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

将鉴别器列映射到具有Doctrine 2的字段

在我的项目中,我有几个类表继承如下:

namespace MyProject\Model;

/**
 * @Entity
 * @InheritanceType("JOINED")
 * @DiscriminatorColumn(name="discr", type="string")
 * @DiscriminatorMap({"person" = "Person", "employee" = "Employee"})
 */
class Person
{
    // ...
}

/** @Entity */
class Employee extends Person
{
    // ...
}
Run Code Online (Sandbox Code Playgroud)

我有一个方法,它根据具有公共getter的字段将实体转换为数组.这里的问题是我丢失了数组中的继承信息,因为鉴别器值没有存储在字段中.

所以我尝试的是以下内容,希望教义会自动设置$disc:

class Person
{
    // can I automatically populate this field with 'person' or 'employee'?
    protected $discr;

    public function getDiscr() { return $this->discr; }
    public function setDiscr($disc) { $this->discr; }

    // ...
}
Run Code Online (Sandbox Code Playgroud)

有没有办法在学说中使这项工作?或者我需要在实体到数组方法中读取类元数据?

doctrine-orm

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

无缩放动画ImageView宽度

我正在尝试为ImageView设置动画,以便从左到右慢慢显示.当我在解释我想要的东西之前问这个问题时,所以这次我使用HTML/JS创建了所需的效果:

http://jsfiddle.net/E2uDE/

在Android中获得此效果的最佳方法是什么?

我尝试更改scaleType,然后将ScaleAnimation直接应用于该ImageView:

布局:

<ImageView
    android:id="@+id/graphImage"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:scaleType="centerCrop"
    android:background="@android:color/transparent"
    android:contentDescription="@string/stroom_grafiek"
    />
Run Code Online (Sandbox Code Playgroud)

Java的:

scale = new ScaleAnimation((float)0,
        (float)1, (float)1, (float)1,
        Animation.RELATIVE_TO_SELF, (float)0,
        Animation.RELATIVE_TO_SELF, (float)1);
scale.setDuration(1000);

graphImage.startAnimation(scale);
Run Code Online (Sandbox Code Playgroud)

但这个stil缩放图像.

我也尝试在FrameLayout中包装ImageView,希望我能为FrameLayout设置动画:

<FrameLayout
    android:layout_width="70dp"
    android:layout_height="fill_parent"
    android:clipChildren="true"">
    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|left|clip_horizontal" />
</FrameLayout>
Run Code Online (Sandbox Code Playgroud)

这仍然会尝试扩展我的ImageView以适应FrameLayout.

android android-layout

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

dart:js 在调用 promiseToFuture 时出错 - NoSuchMethodError: 试图调用一个非函数,例如 null: 'jsPromise.then'

我正在尝试等待自定义的全局 JavaScript 函数:

  var promise = js.context.callMethod('performAuthenticationInNewWindow', [uri.toString()]);
  print(promise);
  var qs = await promiseToFuture(promise);
Run Code Online (Sandbox Code Playgroud)

打印以下内容:

[object Promise]
NoSuchMethodError: tried to call a non-function, such as null: 'jsPromise.then'
Run Code Online (Sandbox Code Playgroud)

dart-js-interop flutter flutter-web

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

在knockout.js中创建一个脏标志绑定

我正在尝试创建一个绑定处理程序,它允许我跟踪绑定中使用的任何值是否已更改:

<div id="container1" data-bind="dirty: $root.container1Dirty">
    <span data-bind="visible: $root.container1Dirty">*</span>

    <label>
        Text 1
        <input data-bind="value: $root.text1" />
    </label>
</div>
Run Code Online (Sandbox Code Playgroud)

到目前为止我尝试了以下内容:

ko.bindingHandlers.dirty = {
    init: function(element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {

        var counter = 0;
        var dirtyObservable = valueAccessor();
        var appliedBindings = false;

        var computed = ko.computed(function() {
            if (!appliedBindings) {
                // I was hoping this would subscribe all the used observables
                ko.applyBindingsToDescendants(bindingContext, element);
                appliedBindings = true;
            }
            // make sure subscribe is triggered by returning a new value
            return counter++; 
        });
        computed.subscribe(function() …
Run Code Online (Sandbox Code Playgroud)

knockout.js

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

从第一个参数中自动推断第二个通用参数

我有以下接口来定义表的列:

export interface IColumnDefinition<TRow, TField extends keyof TRow> {
    field: TField;
    label?: string;
    formatter?: (value: TRow[TField], row: TRow) => string;
}
Run Code Online (Sandbox Code Playgroud)

现在我想要的是只提供行的类型 ( TRow),让 TypeScriptTField根据field属性中的值自动推断字段的类型 ( ) 。

现在假设我的行有以下界面:

interface User {
    name: string;
    birthDate: number;
}
Run Code Online (Sandbox Code Playgroud)

我尝试的是以下内容:

const birthDateColumnDefinition: IColumnDefinition<User> = {
    field: 'birthDate',
    formatter: value => new Date(value).toDateString(),
}
Run Code Online (Sandbox Code Playgroud)

这给了我以下错误:

通用类型 'IColumnDefinition<TRow, TField extends keyof TRow>' 需要 2 个类型参数。

我还尝试过使用函数来创建定义,希望可以从参数中推断出类型:

function createColumnDefinition<TField extends keyof TRow>(
    field: TField,
    columnDef: Partial<IColumnDefinition<TRow, TField>>): IColumnDefinition<TRow, TField>
{ …
Run Code Online (Sandbox Code Playgroud)

typescript

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

插入..使用zend db从...中选择

我有以下原始查询将项目从购物车移动到订单表:

insert into webshop_order_item (
    order_id,
    product_id,
    count
)
select
    1,
    product_id,
    count
from 
    webshop_cart
Run Code Online (Sandbox Code Playgroud)

我正在使用Zend DB进行所有建模.我想知道是否有一种方法可以实现上述查询的目标而无需使用原始查询?

php zend-db

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

将整个文档移动到iframe中

我正在尝试做的是包装一个完整的网站,iframe而不破坏任何样式或JavaScript.

这就是我尝试过的:

var $frame = $('<iframe />').css({
    position: 'fixed',
    top: 0,
    left: 0,
    width: '100%',
    height: '100%'
}).appendTo('body');

$('head').children().appendTo($frame.contents().find('head'));
$('body').children().not($frame).appendTo($frame.contents().find('body'));
Run Code Online (Sandbox Code Playgroud)

http://jsfiddle.net/gUJWU/3/

这在Chrome中运行良好.

Firefox似乎吞下了整个页面.

Internet Explorer(请参阅http://jsfiddle.net/gUJWU/3/show/)确实创建了iframe,不会移动任何内容.

这种方法是否有可能跨浏览器工作?

javascript iframe

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

动画从左到右显示ImageView

可能重复:
无缩放动画ImageView宽度

我想要做的是创建一个动画,其中从左到右显示ImageView(剪辑动画?).图像不应缩放.

我尝试更改scaleType,然后将ScaleAnimation直接应用于该ImageView:

布局:

<ImageView
    android:id="@+id/graphImage"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:scaleType="centerCrop"
    android:background="@android:color/transparent"
    android:contentDescription="@string/stroom_grafiek"
    />
Run Code Online (Sandbox Code Playgroud)

Java的:

scale = new ScaleAnimation((float)0,
        (float)1, (float)1, (float)1,
        Animation.RELATIVE_TO_SELF, (float)0,
        Animation.RELATIVE_TO_SELF, (float)1);
scale.setDuration(1000);

graphImage.startAnimation(scale);
Run Code Online (Sandbox Code Playgroud)

我还尝试将ImageView放在RelativeLayout中,然后将动画应用于RelativeLayout:

布局:

<RelativeLayout 
    android:id="@+id/graphImageInnerWrap"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@android:color/transparent"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:clipChildren="true"
    >
    <ImageView
        android:id="@+id/graphImage"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:scaleType="matrix"
        android:background="@android:color/transparent"
        android:contentDescription="@string/stroom_grafiek"
        />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

Java的:

scale = new ScaleAnimation((float)0,
        (float)1, (float)1, (float)1,
        Animation.RELATIVE_TO_SELF, (float)0,
        Animation.RELATIVE_TO_SELF, (float)1);
scale.setDuration(1000);

graphImageInnerWrap.startAnimation(scale);
Run Code Online (Sandbox Code Playgroud)

在这两种情况下,ImageView仍在缩放.我希望有人能指出我正确的方向.

android

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