如何使用angularjs通过url获取加密数据

时间:2015-10-24 07:50:04

标签: angularjs spring spring-mvc

我用spring mvc和angularjs做项目。我使用@ResponseBody在json中查询数据加密存储,如下所示:

@RequestMapping("getEmpListRB")
    public @ResponseBody String getEmpListsRB() throws Exception {
        ObjectMapper mapper = new ObjectMapper();
        List<EmployeeTest> employeeList = new ArrayList<EmployeeTest>();
        employeeList = dataService.getList();
        String jsonInString = mapper.writeValueAsString(employeeList);
        String encryptData = AES.encrypt(jsonInString);
        return encryptData;
    }

当我像这样运行项目访问url(url / getEmpListRB)时,我得到如下数据:

V70kQm5oilgPr/VdmGqEv3Lkg7P/lSWccjs6F/scOuIiR/NAM7dXMtmYrliW5Nc1g8TQEEZ7m2g8 9TrlJBIbr6iyvAHD/q+l8rzGfR6hYDLl61VhxrTMYsCgVVPPyBUiBKaoJJvC/MsJTv8HV61ZiZe9 NGziNQNt9HF/k40RzlGsfWtSibVrGTxbhYue45QSSNIjKHg0bA3+El431tyBgMbd1/mPxdSdJpMQ F4H230eiH8tnALC2pKaDDlTEDt7MpkR9V0V7ovQf2aCwOVRzShydm2kAxv1W54zLjggTIlXA1Eb6 ywkcdS6eN7Wzci+DFIJKX2r0KjMIvnKR5ij7OsnoxUPrU2bdqMwAiE0Ld1J0DixMYmrsiyj3qTOL GO8qodDNt6FcW1jfOMqzMbH11uxDp1LJAdfJ8xlBDrrOrSmKmWN9vHLCF8zXm17MAHpVt+S4GneA 8nL2fu+O4t+JjEupoIXjZsf5bBngkNB/m02/lH/HHL2sc33uKKTgdBkt+nk9QjlQeIvIPcV5dPPe rkPkxCJPSVPjomoVWkjuBonaj5DtFqRufjnNVfl5ZmZjnhG3ewN0kYHJKGGC4jFLobykQT5C9qxK V5R8z+czZGer8JHwqpfwVpLnQRvbMi7pLj2lR7j7hCzZhQu1HKXB89V4+1Vf/ZlwmlvZ/TU12uxG 0L8pPfvk5NK6e55UKz6ZFNWCIXJmKcySlwIHNIkK0Ygm+NWofxR9HnuJzzruJqIbKCMcbebCHm5f p64MchTlIvRsu72NHzJWys9gdT2GFgBMVj9d5gSnDJlvrnpxP5MEcUNo/datc9Gk38dntlweqqcj WmUuChbSGw70AnuKd2/lAZuNhMec6kw+MfYYo3yijnepyJKEV6ykeoERzhDtZpyWcjYGxyWMjb2X g7VMm+KXCyiVhI9+gMETPKgI5M7sAYlLI7tj6J/WcOWCuHgCzNKDYADriSL9DRBk/trVZrqUwsKP wgjutw6vVtL9mI7ojLa8GkDu47dqCeGNdfzSf0043Im3ypVu+442usN4bpgf3rHdujaxcs0G+j0y cYKniLywXiHtVpT8IfWVNjc3PgaFKW1QTqsJC3AVefVqKt9944bKRif3uu7dqXLw5L7WpWF0I+qK EBv9MbeiNEO3BzNNfpdeoJusG0wuZ9AB3MZgMGMGwg4rDuDBsjI5x+vtjr+8voKZuDBzhx1/6xOp C6QqMC6gG9rkI69uLfT/OIf/X0RB4mlxRti7EPVDg4Oe+KTfH/S07Ce0O6DnL3Q78l7/UoW8iowg 1RTtSTwCaI9JQjA5c0oTEXcUH1aYcOjUbynwIUKznFZpMTJOq9YqORudQ09rlyfHQImdgsWa1RCL YAC80Nzd/0NV2t4hjf13ZvJ3Z68GZaFwqLOWrAV1XYM4N35z9MYwKx1CzVN5bITB7KAMnfmyAEKx H+0N9cRvbtaZjbKJ0z5O7vvnnISbRreMQ+Xg838tk9w7A8Dm3w==

然后我使用下面的angularjs作为警报加密数据,但我无法提醒它请帮助我!

<!DOCTYPE html>
<html data-ng-app="formSubmit">
<head>
<meta charset="ISO-8859-1">
<title>AngularJS Post Form Spring MVC example</title>
<!-- <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.8/angular.min.js"></script> -->
<script src="${pageContext.request.contextPath}/resources/js/angular.min.js"></script>
<script type="text/javascript">
    var app = angular.module('myApp', []);
    app.controller('customersCtrl', function($scope, $http) {
      $http.get("http://" + location.host + "/MdrWebService/getEmpListRB").success(function (response) {
          $scope.names = response;
          alert(JSON.stringify(response));
       });
    });
</script>
</head>
<body>
    <div ng-app="myApp" ng-controller="customersCtrl">

    </div>  
</body>
</html>

0 个答案:

没有答案