鍍金池/ 問答/ 網(wǎng)絡(luò)安全問答
墨染殤 回答

Caused by: java.lang.ClassNotFoundException: javax.servlet.ServletContext

在pom.xml里加入servlet依賴:

<!-- https://mvnrepository.com/artifact/javax.servlet/servlet-api -->
<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>servlet-api</artifactId>
    <version>3.0.1</version>
    <scope>provided</scope>
</dependency>
風(fēng)畔 回答

mysql5.7支持json

懶洋洋 回答

必須在類屬性中事先把這個對象創(chuàng)建出來,在構(gòu)造函數(shù)中設(shè)定這個屬性的值。

from flask_wtf import FlaskForm
class Auth(FlaskForm):
 
    selects = SelectField('selects')
    
    def __init__(self):
        super(Auth, self).__init__()
        self.selects.choices = [('value', 'text'), ('value', 'text')]
荒城 回答

cpu 和 goroutine 默認(rèn)情況下并不是 1:1 的關(guān)系,對各個 goroutine 的調(diào)度是 go runtime 的調(diào)度器決定的

何蘇葉 回答
    function async2() {
        console.log( 'async2');
    }
    async function async1(resolve) {
        await setTimeout(function () {
            console.log("settimeout");
            //當(dāng)我認(rèn)定async1完成后才開始async2
            resolve()
        },0);
    }
    new Promise(function (resolve) {
        async1(resolve)
    }).then(function () {
        async2()
    });
或者
new Promise(function (resolve) {
        async1()
        resolve()
    }).then(function () {
        async2()
    });
嫑吢丕 回答

其實就是創(chuàng)建數(shù)組,數(shù)組每一項就是一個函數(shù), a[n]() 執(zhí)行數(shù)組里的第N個函數(shù)
例如:

var a = []; //創(chuàng)建數(shù)組賦值
a[1] = function () {
    console.log(1);
  };
a[2] = function () {
    console.log(2);
  };
a[3] = function () {
    console.log(3);
  };

//a =[a[1],a[2],a[3]]

a[3]() // 3

影魅 回答

感謝這位大神,寫的都很清楚了,http://blog.csdn.net/xu122723...。

問題的主要原因是,雖然tomcat已經(jīng)攔截了404,并指向了我的index頁面,但是這個404的標(biāo)記還是存在,只要遇見存在404錯誤頁處理的平臺,就gg了。就比如微信平臺,他檢測到你的404,就立馬跳向公益404頁面了。

解決方法一:后臺設(shè)置攔截器,在發(fā)送任何請求前,后臺都做攔截,并指向index頁面。

解決方法二:用nginx進行攔截,修改nginx.conf文件

http {

# 此處省略好多字

server {

    # nginx才配使用80端口,其他服務(wù)速速離去
    listen       80;

    # 沒啥好解釋的
    server_name  localhost;

    # 指定根目錄,由于我的前端項目是直接放在nginx下的html文件夾,所以我這樣配
    root html;

    # 這里其實是由if變過來的,意思是如果uri存在,那就訪問uri的資源,如果uri不存在,那就訪問該目錄下index.html文件。如果看不懂我的解釋,可以看這個https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/#front-controller-pattern-web-apps
    try_files $uri $uri/ /index.html;

    # 這里是配你Tomcat里面的其他java項目,意思是當(dāng)你訪問http://ip/xxx的時候,會到這個代碼塊里面進行對應(yīng)操作
    location /xxx {
        # 這些照著加就好了,無非是獲取服務(wù)器host/ip相關(guān),一定要加,否則如果你的項目并不是前后端分離,而是SSH/SSM帶有jsp或者模板頁面的,那就會出現(xiàn)找不到css/js等找不到一切靜態(tài)資源文件的錯誤。為什么會報錯,因為你看network面板你就知道,他是去訪問http://127.0.0.1/xxx/css...而并不是訪問服務(wù)器的真實ip,所以還是乖乖加上吧!
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header REMOTE-HOST $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        # 去該地址去找項目資源
        proxy_pass http://127.0.0.1:8080/xxx;
    }
  }
}
情已空 回答

先去了解下socket的原理再說,socket客戶端和服務(wù)端是怎么交互的

拽很帥 回答

把button的默認(rèn)padding去掉 padding:0px

薄荷糖 回答

uploadify有flash版本和h5版本的,高級瀏覽器可以用h5版的

老梗 回答

You can use iptables's filter table not nat table

執(zhí)念 回答

建一個任務(wù)數(shù)組,并監(jiān)聽這個數(shù)組對象,sts不存在時將需要執(zhí)行的回調(diào)存起來,ready完成和數(shù)組變化時都去檢查任務(wù)隊列長度 依次調(diào)用回調(diào) 回調(diào)然后在任務(wù)隊列數(shù)組刪除該回調(diào) 這樣你就不用去管他是否加載了,沒加載就會把任務(wù)依次掛起,加載完成了就會先把一個任務(wù)放進任務(wù)隊列,然后立即拿出來執(zhí)行

linux 和 windows 的文件系統(tǒng)是不同的。

  1. windows 文件路徑寫法和 linux 的不同。
  2. windows 文件名不區(qū)分大小寫的,而 linux 區(qū)分的。

我不是很懂這個 solr 技術(shù),但我覺得可能是文件系統(tǒng)的不同造成的錯誤。

焚音 回答

在路由中使用重定向試試,匹配到有#!的重定向到現(xiàn)有的項目路由上,并且把參數(shù)也帶上。 當(dāng)然,這是我的猜想,我也沒具體實現(xiàn)過這種情況。

離夢 回答

目前找到一個添加用戶的方法,用guest登錄http://127.0.0.1:15672
在Admin欄目下有一個ADD a USER 可以添加一個新的用戶,并給他設(shè)置權(quán)限

敢試 回答

pool.getConnectionconnection.query如果沒有promise/async寫法的話,你就手動實現(xiàn)各promise吧。

function search(searchtext) {
    return new Promise((resolve, reject) => {
        var resdata = {};
        if (safetytest(searchtext)) {
            pool.getConnection(function (err, connection) {
                if (err) reject(err); // reject
                connection.query(
                    function (err, result) {
                        if (err) reject(err); // reject
                        resdata = {
                        };
                        resolve(resdata); // resolve
                    }
                );
            });
        }
    })
}

有的話可能就是這樣了。

async function search(searchtext) {
    var resdata = {};
    // 安全檢查
    if (safetytest(searchtext)) {
        try {
            const connection = await pool.getConnection()
            const resdata = await connection.query()
            return resdata
        } catch (err) {
            throw err
        }
    }
}