小编Mit*_*tro的帖子

我应该何时在独立的node.js上使用express.js.

Node.js是一个javascript环境

Express是一个框架

什么是软件框架?对于Node.js?

为什么以及何时在独立的Node.js上使用Express框架是有用的?

我的意思是,这个框架只是一组现成的函数和模块,可以更容易地从头开始编写代码吗?

我问这个是因为我在ExpressJ上找到了很多关于NodeJS的教程和指南,但只有一些关于独立NodeJ的教程和指南.

javascript node.js express

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

JAVA无法对非静态字段进行静态引用

这是我在JAVA的第一个程序,我遇到了解这个错误的问题

Cannot make a static reference to the non-static field *
Run Code Online (Sandbox Code Playgroud)

无法对非静态方法进行静态引用*

public class Cerchio{

   float r;
   float area;
   float cfr;
   final double pi = 3.14;

   public static void main(String[] args){
      System.out.println("CIRCLE PROGRAM\n");
      r = 5;
      c_cfr();
      c_area();
      System.out.ptintln("The cir is: " + cfr);
      System.out.println("The area is: " + area);
   }

   float c_cfr(){
      cfr =(float)(2 * pi * r); //casting
      return cfr;
   }

   float c_area(){
      area = (float)(pi * (r*r));
      return area;
   }

}
Run Code Online (Sandbox Code Playgroud)

错误 你能给我一些建议吗?我正在使用Android上的SandIDE进行编码

java

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

使用jQuery在WordPress中加载图像

我正在为WordPress开发一个模板页面,当我点击一个按钮时namesite.com/wordpress/test我需要加载一个图像,我需要加载一个图像

$("<img src='wp-content/themes/twentytwelve/images/loader.gif' class='loader' />").appendTo("#contact");
Run Code Online (Sandbox Code Playgroud)

问题是图像没有被搜索wordpress/wp-content/themes/twentytwelve/images/loader.gif但是wordpress/test/wp-content/themes/twentytwelve/images/loader.gif因为我有错误.我能怎么做?

wordpress jquery path

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

如何在MacOS上安装Firefox OS SDK?

我想开始为Firefox OS开发,但是我有安装问题..我正在关注mozilla的wiki,但现在我不知道如何继续.我已经下载了XULRunner,但那我该怎么办?我正在尝试关注维基,但没有找到解决方案.

链接:https://developer.mozilla.org/en-US/docs/Getting_started_with_XULRunner

firefox-os

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

PHP --version 在 osX 上显示不正确

我已经从自制软件安装在我的 osX php7 中,但是当我在 shell 中输入时,php --version或者php-fpm --version我得到一个旧版本

PHP 5.5.30 (fpm-fcgi) (built: Oct 23 2015 17:22:03) Copyright (c) 1997-2015 The PHP Group Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies

从 shell 中,我查找了每个 php 文件或文件夹,sudo find / -name "php"但没有与 PHP 5.5 相关联

我该怎么办?

php macos

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

在 Spring Cloud Stream Kafka 中正确管理 DLQ

我想使用 kafka 在 Spring Cloud Stream 中管理 DLQ。

应用程序.yaml

server:
    port: 8091
eureka:
    client:
        serviceUrl:
            defaultZone: http://IP:8761/eureka
spring:
    application:
        name: employee-consumer
    cloud:
        stream:
            kafka:
                binder:
                    brokers: IP:9092
                bindings:
                    greetings-in:
                        destination: greetings
                        contentType: application/json
                    greetings-out:
                        destination: greetings
                        contentType: application/json
            bindings:
                greetings-out:
                    consumer:
                        enableDlq: true
                        dlqName: dead-out
    kafka:
      consumer:
        group-id: A
Run Code Online (Sandbox Code Playgroud)

正如您在我的配置中看到的,我启用了 dlq 并为 dlq 主题设置了一个名称。

为了测试 DLQ 行为,我对某些消息抛出异常

我的监听器组件

@StreamListener("greetings-out")
    public void handleGreetingsInput(@Payload Greetings greetings) throws Exception {
        logger.info("Greetings input -> {}", greetings);
        if (greetings.getMessage().equals("ciao")) {
            throw new Exception("eer");
        }
    } …
Run Code Online (Sandbox Code Playgroud)

apache-kafka spring-boot spring-cloud-stream

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

在C中生成随机数组

我正在使用OpenVMS在C中开发,我已经完成了一个代码,该代码放入1001(0-1000)个元素数组,1000(0-999)个0到50之间的随机数.这是代码:

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

main(){
    int vet[1000], fre[50];
    int i;

    srand(time(NULL));

    for(i=0;i<1000;i++){
        vet[i]=(rand()%51);
    }

    for(i=0;i<1000;i++){
        printf("%d\n", vet[i]);
    }

    for(i=0;i<1000;i++){
        fre[vet[i]]=fre[vet[i]]+1;
    }

    for(i=0;i<51;i++){
        printf("The number %d  was generated %d times\n", i, fre[i]);
    }
}
Run Code Online (Sandbox Code Playgroud)

当我显示每个数字生成的次数时,我看到数字50的数字很大,有时比其他数字多一倍,有人可以帮助我吗?

已解决的代码我现在必须使用srand()

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

main(){
        int vet[1000], fre[51] = {0};
        int i;

        srand(time(NULL));

        for(i=0;i<1000;i++){
                vet[i]=(rand()%51);
        }

for(i=0;i<1000;i++){
printf("%d\n", vet[i]);
}

        for(i=0;i<1000;i++){
                        fre[vet[i]]=fre[vet[i]]+1;
        }

        for(i=0;i<51;i++){
                printf("The number %d  was generated %d times\n", i, fre[i]);
        }
}
[EOB]
Run Code Online (Sandbox Code Playgroud)

谢谢你们

c openvms

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

C中的文件管理

我在C语言中训练文件管理,我看到有很多方法可以用fopen打开一个文件,使用单词作为a,r等等.一切都好,但我还读到如果那个单词我添加b那个成为二进制文件.这是什么意思?与普通文件的区别是什么?

c file

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

在OpenVMS上开发大会?

有人可以解释我如何在OpenVMS上进行汇编开发,我已经在OpenVMS上用C开发了,我刚开始在Windows和Linux中进行汇编.如何编译,链接和运行.asm程序?

assembly linker compilation vms openvms

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

二进制搜索练习

我正在用C做练习,但我不知道为什么第一个结果我总是-1(这是不可能的).我只有在交换后才能对数组进行纵坐标.

#include <stdio.h>
#include <time.h>
#include <stdlib.h>

main(){
        int vet[100], cont[100];
        int i, c, f=100;
        int swap;
        int r=0;
        int search;

        srand(time(NULL));

        for(i=0;i<100;i++){
                vet[i]=rand()%100+1;
        }

        while(r==0){
                r=1;
                for(i=0;i<100;i++){
                        if(vet[i]>vet[i+1]){
                                swap=vet[i+1];
                                vet[i+1]=vet[i];
                                vet[i]=swap;
                                r=0;
                        }
                }
        }

        for(i=0;i<100;i++){
                printf("%d) %d\n", i+1, vet[i]);
        }

        i=0;
        r=0;
        printf("Inserisci numero da ricercare (1-10000) -> ");
        scanf("%d", &search);
        if(search>10000 || search<0){
                printf("Hai inserito un valore non valido\n");
        }
        else{
                c=(i+f)/2;
                while(vet[c]!=search && i<f){
                        if(vet[c]<search){
                                i=c+1;
                                c=(i+f)/2;
                        }
                        else if(vet[c]>search){
                                f=c-1;
                                c=(i+f)/2;
                        }

                        if(vet[c]==search){
                                cont[r]=c+1;
                                r++; …
Run Code Online (Sandbox Code Playgroud)

c openvms

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

字符串,获取和做

我正在进行C练习,但是我遇到问题并且我想要重复cicle(do while),事实上如果我输入1,程序再次从顶部开始,但它不会停止在gets(testo);.我尝试了很多方法来解决没有解决方案的bug,任何人都可以帮助我吗?

#include <stdlib.h>
#include <stdio.h>
#include <string.h>

main(){
        int cch, cw, i, j, w, ord, f; //counter and index
        char testo[80];
        char alfa[50][25];
        char swap[25];

        do{     
                cch=0;
                cw=0;
                j=0;
                w=0;
                f=0;

                for(i=0;i<80;i++){
                        testo[i]='\0';
                }
                printf("Write the text:\n");
                gets(testo);

                //initialization 2d array
                for(i=0;i<50;i++){
                        for(j=0;j<25;j++){
                                alfa[i][j]='\0';
                        }
                }

                j=0;
                //Count word and characters
                if(testo[0]!='\0'){
                        cw=1;   
                        for(i=0;testo[i]!='\0';i++){
                                cch++;
                                if(testo[i]==' '){
                                        cw++;
                                        j++;
                                }
                        }
                }

                if(cch==j){
                        printf("You haven't written any word\n\n");
                }
                else{
                        //Don't count double space
                        for(i=0;i<cch;i++){
                                if(testo[i]==' ' …
Run Code Online (Sandbox Code Playgroud)

c string gets openvms

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

Java中未处理的异常类型IOException

我刚刚开始使用Java,因此我犯了很多错误,我已经解决并了解了很多错误,但现在我遇到了输入问题.我看到有两种输入:InputBufferedReader和Scanner,但我读到第一种更好(我不知道为什么),所以我正在使用它.

我得到的错误是: IOException异常

import java.io.InputStreamReader;
import java.io.BufferedReader;

public class Cerchio{

  private float r;
  private float area;
  private float cfr;
  final double pi = 3.14;


  public static void main(String[] args){
    System.out.println("Programma cerchio\n");

    Cerchio cerchio = new Cerchio(); 
    cerchio.getR();
    cerchio.c_cfr();
    cerchio.c_area();
    System.out.println("La circonferenza è: " + cerchio.cfr);
    System.out.println("L area è: " + cerchio.area);
  }

  private float getR(){
    InputStreamReader input = new InputStreamReader(System.in);
    BufferedReader num = new BufferedReader(input);

    try{
      String sr = num.readLine();
      r = Float.valueOf(sr).floatValue();
    } catch(NumberFormatException nfe){
        System.out.println("Incorrect!!!");
      }
    return r; …
Run Code Online (Sandbox Code Playgroud)

java

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