第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

登錄后/剛剛刷新頁(yè)面后未加載數(shù)據(jù)

登錄后/剛剛刷新頁(yè)面后未加載數(shù)據(jù)

寶慕林4294392 2022-01-19 09:54:12
我在我的頁(yè)面上進(jìn)行了簡(jiǎn)單的登錄。登錄后,我正在顯示來(lái)自服務(wù)器的數(shù)據(jù),這只是在刷新頁(yè)面一次后顯示。在我收到錯(cuò)誤 500 之前:GET http://localhost:8080/getDesktop 500angular.js:14800 Possibly unhandled rejection: ...我的 AngularJS 代碼如下:var app = angular.module("myApp", []);app.controller("myCtrl", function($scope, $http, $window, $timeout){//Username$scope.user  = "";//Desktop$scope.storage = [];//Get username$http.get("/loggeduser", {transformResponse: function(response){        return JSON.stringify(response);    }}).then(function(response) {    $scope.user = response.data.substring(1, response.data.length-1);});//Show Desktop    $http.get("/getDesktop").then(function(response){    for(var i = 0; i<response.data.length; i++){           $scope.storage[i] = {name: response.data[i]};       }                  return;   });});后端://Returns Desktop@GetMapping("/getDesktop")public ArrayList<String> getDesktop() throws Exception {    ArrayList<String> itemNames = new ArrayList<>();    if(kdxF.getUser() != null) {        itemNames = kdxF.showDesktop();          // Just a function to return the Elements in an ArrayList if Strings        // If user is logged in    }else {        throw new Exception("Not logged in!");    }    return itemNames;}我收到消息“未登錄”
查看完整描述

1 回答

?
桃花長(zhǎng)相依

TA貢獻(xiàn)1860條經(jīng)驗(yàn) 獲得超8個(gè)贊

好的,我用一個(gè)丑陋的解決方案解決了它,但它有效。我不斷檢查用戶是否為空,然后加載數(shù)據(jù)。


//Returns Desktop

@GetMapping("/getDesktop")

public ArrayList<String> getDesktop() throws Exception {

    ArrayList<String> itemNames = new ArrayList<>();

    int kill = 0; 


    while(kdxF.getUser() == null) {    // FIXME

        if(kill == 500) {

            break;

        }else {

            Thread.sleep(5);

            kill++;

        }

    }


    itemNames = kdxF.showDesktop();


    return itemNames;

}

如果你有更好的建議,請(qǐng)告訴我。:)


查看完整回答
反對(duì) 回復(fù) 2022-01-19
  • 1 回答
  • 0 關(guān)注
  • 193 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)