簡體   English   中英

GET服務調用未從Controller調用

[英]GET Service call is not getting called from Controller

我試圖將Angular引入我的舊應用程序之一。 但是不確定為什么不調用服務。 以下是JS文件中的代碼。 早些時候,我在瀏覽器中遇到錯誤,說無法解析$ http。 所以我只是在函數中傳遞了它。

var app = angular.module('ldlApp', []);
app.controller('ldlController', function($scope,$http) {
  console.log(" Inside Controller **** ");
  $scope.message = 'Hello from LDL Controller !!!! ';
  $scope.BLT_LDL_DECESION_LOAN_DATA = [];
  console.log(" Going to Hit the Service ***** ");
  $http.get("/Services/ldl/getdetails")
    .then(function(response) {
      $scope.BLT_LDL_DECESION_LOAN_DATA = response.data;
      console.log("BLT_LDL_DECESION_LOAN_DATA: 
            "+JSON.stringify($scope.BLT_LDL_DECESION_LOAN_DATA));
      });
  });

下面是Java文件中的REST控制器

@RestController
public class LoanDecesionController {

   @RequestMapping(value = "/Services/ldl/getdetails", method = RequestMethod.GET)  
   @ResponseBody
   @Transactional
   public List<LinkedHashMap<String, Object>> getdetails() throws Exception {
      System.out.println(" Inside Service **** ");
      List<LinkedHashMap<String, Object>> dataMap = new ArrayList<LinkedHashMap<String, Object>>();
      LinkedHashMap<String, Object> responsedataMap = new LinkedHashMap<>();
      responsedataMap.put("SUCESS", "Called the service ");
      dataMap.add(responsedataMap);
      return dataMap; 
   }

}

在瀏覽器中,我可以看到類似的消息

Inside Controller **** 
Going to Hit the Service ***** 

以下是我在“網絡”標簽中看到的內容。

Request URL: https://*****-*****-*****.com/Services/ldl/getdetails
Request Method: GET
Status Code: 302 Found
Remote Address: 10.***.***.49:553
Referrer Policy: no-referrer-when-downgrade

但是我沒有控制器中的sysouts。 因此,問題究竟出在響應上還是影響服務。

使用@Transactional@ResquestMaping春季啟動時,請勿自動配置URL映射。 從您的方法中刪除@Transactional並嘗試在代碼中的其他地方管理事務

看來我現有的應用程序正在阻止該URL,並且不允許訪問任何其他URL。 感謝大家的幫助,並提供了對問題的深刻見解。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM