小编Eri*_*pie的帖子

Java模型的JSON字段映射

发送的JSON:

{
  "Banner": "ABC"
}
Run Code Online (Sandbox Code Playgroud)

Java模型:

...
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
public class BannerData implements java.io.Serializable {

    private static final long serialVersionUID = 5664846645733319592L;

    @JsonProperty(value = "Banner")
    private String banner;

    public String getBanner() {
        return banner;
    }

    public void setBanner(String banner) {
        this.banner = banner;
    }
}
Run Code Online (Sandbox Code Playgroud)

控制器:

@RequestMapping(value = {"/GetBanner"}, method = RequestMethod.POST)
@ResponseBody
public ResponseEntity<String> enrollCustomer(@RequestBody BannerData body, HttpServletRequest request) throws Exception {
...
}
Run Code Online (Sandbox Code Playgroud)

请求/GetBanner返回:
客户端发送的请求在语法上是不正确的.

工程确定当JSON变更为(小写字母命名的就是Java字段名):

{
  "banner": "ABC"
}
Run Code Online (Sandbox Code Playgroud)

但是我需要在 …

java json jackson deserialization

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

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

Kendo Grid中的寻呼机错误(Nan-Nan of 1 items)

我正在尝试创建一个包含学生详细信息列表的Kendo网格.点击添加按钮,寻呼机显示"Nan-Nan of 1 items".

@(Html.Kendo().Grid<Student.Models.StudentDetails>()
            .Name("StudentDetailsGrid")
             .Pageable()
                 .HtmlAttributes(new { id="StudentDetailsGrid"})
            .Columns(col =>
                {col.Bound(a => a.FirstName).Title("Name");

                    col.Bound(a => a.LastName).Hidden()
                    col.Bound(a => a.StudentID).Hidden();
                    col.Command(a => { a.Destroy(); a.Edit(); }).Title("");
                }
            )
            .ToolBar(toolbar => toolbar.Create().Text("Add").HtmlAttributes(new {@id="btnCreateStudent"}))
            .Editable(editable => editable.Mode(GridEditMode.InLine))
                .Scrollable(scrol => scrol.Enabled(true))

            .DataSource(source => source
                .Ajax()
                .PageSize(5)

                .Model(a =>
                {
                    a.Id(b => b.StudentID);


                })

             .Read(read => read.Action()
             .Create(create => create.Action())
             .Destroy(destroy => destroy.Action())
             .Update(update => update.Action())


           ).Events(even => even.Save("SaveDetails").Edit("ChangeNoOfStudent").DataBound("StudentValidate")))
Run Code Online (Sandbox Code Playgroud)

`

在Document.ready函数上:

$(document).ready(function () {
        $.ajax({
                url: '../Student/GetStudentDetails?StudentId=' + Data.StudentId,
                type: 'POST',
                contentType: 'application/json', …
Run Code Online (Sandbox Code Playgroud)

javascript jquery kendo-grid

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

尝试评估Chrome扩展程序中的免费试用版时,"OAuth2未被授予或撤销"

我正在尝试为Chrome扩展程序提供免费试用期,并且一直在关注如何完成此操作的Chrome 文档.

但是,当我的扩展程序加载时,后台脚本会将以下错误记录到控制台:

运行identity.getAuthToken时未经检查的runtime.lastError:未授予或撤消OAuth2.

控制台指向呼叫chrome.identity.getAuthToken作为罪魁祸首.这是我的后台脚本中的相关代码:

var CWS_LICENSE_API_URL = 'https://www.googleapis.com/chromewebstore/v1.1/userlicenses/';

chrome.identity.getAuthToken({
    'interactive': false
}, function(token) {
    console.log('token', token);

    var req = new XMLHttpRequest();
    req.open('GET', CWS_LICENSE_API_URL + chrome.runtime.id);
    req.setRequestHeader('Authorization', 'Bearer ' + token);
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
            var license = JSON.parse(req.responseText);
            console.log('license', license);
        }
    };
    req.send();
});
Run Code Online (Sandbox Code Playgroud)

我的清单是这样设置的(为简洁起见省略了一些部分):

"manifest_version": 2,
"key": "kkkkkkkkkkkkkkk",

"background": {
    "scripts": [
        "background.js"
    ]
},
"permissions": [
    "storage",
    "identity",
    "https://www.googleapis.com/"
],
"oauth2": {
    "client_id": "cccccccccc.apps.googleusercontent.com",
    "scopes": [
        "https://www.googleapis.com/auth/chromewebstore.readonly"
    ]
} …
Run Code Online (Sandbox Code Playgroud)

google-chrome google-chrome-extension oauth-2.0

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

从Jekyll手表中排除目录

我正在使用Jekyll 3.1.1生成一个博客,我最近引入了一个Git钩子来自动发布预推更改.

引入此钩子后,我在运行时开始收到以下错误jekyll serve:

Configuration file: /Users/egillespie/Projects/blog.givingjar.org/_config.yml
            Source: /Users/egillespie/Projects/blog.givingjar.org
       Destination: /Users/egillespie/Projects/blog.givingjar.org/_site
 Incremental build: disabled. Enable with --incremental
      Generating... 
                    done in 0.223 seconds.
        ** ERROR: directory is already being watched! **

        Directory: /Users/egillespie/Projects/blog.givingjar.org/node_modules/git-scripts/bin/hooks

        is already being watched through: /Users/egillespie/Projects/blog.givingjar.org/node_modules/git-scripts/bin/hooks

        MORE INFO: https://github.com/guard/listen/wiki/Duplicate-directory-errors
 Auto-regeneration: enabled for '/Users/egillespie/Projects/blog.givingjar.org'
Configuration file: /Users/egillespie/Projects/blog.givingjar.org/_config.yml
    Server address: http://127.0.0.1:4000/
  Server running... press ctrl-c to stop.
Run Code Online (Sandbox Code Playgroud)

什么是特殊的是我排除node_modules_config.yml:

exclude:
  - Gemfile
  - Gemfile.lock
  - LICENSE
  - README.md
  - package.json
  - Gruntfile.js
  - node_modules
Run Code Online (Sandbox Code Playgroud)

node_modules …

jekyll

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

如何在JavaScript中将1e-8转换为0.00000001

如何转换1e-80.00000001在JavaScript?

我正在使用Angular,它在使用时不喜欢短语法<input type="number">.

javascript angularjs

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

Angularjs:表单验证和输入指令

我在AngularJS应用程序中创建了一个指令,该应用程序在我的应用程序中生成样式输入.它看起来像这样:

AC.directive('formInput',function ($compile) {
    return {
        transclude: true,
        replace: true,
        scope:{},
        templateUrl: '/views/partials/form/input.html',
        restrict: 'E',
        link: function(scope, element, attrs){

            scope.opts = attrs;

            if(attrs.ngModel){
                element.find('input').attr('ng-model', attrs.ngModel);
                $compile(element.contents())(scope.$parent);
            }

            if(!attrs.type){
                scope.opts.type = 'text';
            }
        }
    };
  }
)
Run Code Online (Sandbox Code Playgroud)

它的模板是:

<label class="acxm-textfield {{opts.cssclass}}">
  <span ng-bind="opts.labeltext"></span>
  <input type="{{opts.type}}" name="{{opts.inputname}}" value="{{opts.inputvalue}}" placeholder="{{opts.placeholder}}" ng-maxlength="{{opts.maxLength}}"/>
</label>
Run Code Online (Sandbox Code Playgroud)

电话很简单:

<form-input ng-model="UserProfile.FirstName" max-length="50" labeltext="{{'GENERAL.name' | translate}}" cssclass="acxm-p-horizontal" inputname="name" inputvalue="{{UserProfile.FirstName}}"></form-input>
Run Code Online (Sandbox Code Playgroud)

我想为这个字段创建验证,我添加了一个错误信息:

<span ng-show="showError(userInfoForm.name,'email')">
                    You must enter a valid email
</span>
Run Code Online (Sandbox Code Playgroud)

并且showError是:

$scope.showError = function(ngModelController, error) {

    return ngModelController.$error[error];
};
Run Code Online (Sandbox Code Playgroud)

基本上,它是从"使用AngularJS掌握Web应用程序开发"一书中复制的.我有一个问题,因为当我记录我的表单时userInfoForm …

html javascript validation angularjs

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

使用 Jekyll Liquid 检查 cookie 是否存在

我正在使用 Jekyll 并设置 cookie 作为检查是否向用户提供关键和异步加载的 CSS,以便只有第一次访问者获得关键和异步 CSS。我正在使用 Filament Groups Enhance.js,它设置 cookie 并负责加载 CSS 异步。我想要做的是使用 Jekyll Liquid 检查 cookie 是否存在,但运气不佳,在我的主要布局中,我有这样的代码:

{% if cookie.name == fullcss %}
  <link rel="stylesheet" href="/css/style.css">
{% elsif page.section == 1 %}
  <style>
    {% include critical-css/getting-started.css %}
  </style>
  <script>
    {% include js/enhance.js %}
  </script>
  <noscript>
    <link rel="stylesheet" href="/css/style.css">
  </noscript>
{% elsif page.section == 1 %}
  ...
Run Code Online (Sandbox Code Playgroud)

基本上这是我想要实现的技术:http : //iamsteve.me/blog/entry/using-cookies-to-serve-critical-css-for-first-time-visits但我不能像我一样使用 PHP我在一个由 GH Pages 托管的 Jekyll 站点上。

liquid jekyll github-pages

5
推荐指数
0
解决办法
1051
查看次数

当 .value 和事件似乎不起作用时,使用 JavaScript 设置文本框的值

我正在尝试为 PayPal 捐赠基金捐赠页面上的文本框设置一个值,但我完全被难住了。

这是我尝试过的:

环境input.value

在 Chrome 开发工具中,如果我运行以下 JavaScript:

document.getElementById('nemo_inputAmount').value = '1'
Run Code Online (Sandbox Code Playgroud)

值“1”出现在文本框中,但是当我单击“立即捐赠”按钮时,该值被清除并且表单不提交。

发送事件

当我按 Tab 键进入文本框、输入值“1”并按 Tab 键退出时,我使用 Chrome 开发工具来监视所有事件。

然后我使用下面的代码重新创建了每个事件。使用此方法,值“1”甚至不会出现在文本框中。我尝试了我能想到的每一种调度事件的组合和风格。

function textEvent(text) {
  let textEvent = document.createEvent('TextEvent');
  textEvent.initTextEvent('textInput', true, true, null, text);
  return textEvent;
}

function setDonationAmount(amount) {
  let amountInput = document.querySelector('input#nemo_inputAmount');

  if (amountInput) {
    console.log('Setting amount to', amount)

    const events = [
      new FocusEvent('focus', {
        composed: true
      }),
      new Event('select', {
        bubbles: true
      }),
      new KeyboardEvent('keydown', {
        bubbles: true,
        cancelable: true,
        composed: true,
        code: 'Digit1', …
Run Code Online (Sandbox Code Playgroud)

javascript google-chrome-devtools

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

如何测试System.out.println(); 通过嘲笑

你好,我必须练习如何使用Mockito,有人可以告诉我如何使用模拟对象来测试基于控制台的输出测试。

Random rand = new Random();
int number = 1+rand.nextInt(100);              // random number 1 to 100
Scanner scan = new Scanner(System.in);

for (int i=1; i<=10; i++){                     // for loop from 1 to 10
    System.out.println(" guess "+i+ ":");``
    int guess = scan.nextInt();
    //if guess is greater than number entered 
    if(guess>number)
        System.out.println("Clue: lower");
    //if guess is less than number entered 
    else if (guess<number )
        System.out.println("lue: Higher");
    //if guess is equal than number entered 
    else if(guess==number) {
        System.out.println("Correct answer after only "+ i …
Run Code Online (Sandbox Code Playgroud)

java unit-testing mockito

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

在SpriteKit中的SKLabelNode的FontColor中不能使用UIColor(红色:,绿色:,蓝色:,)

我不知道为什么我不能用它SpriteKit.如果我尝试UIColor(red:156,green:187,blue:214)颜色变成白色.它不应该是它的颜色,我不知道为什么它不起作用.

ios sprite-kit

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