Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在jhipster中管理来自自定义REST的.json响应数据_Javascript_Angularjs_Json_Spring_Rest - Fatal编程技术网

Javascript 如何在jhipster中管理来自自定义REST的.json响应数据

Javascript 如何在jhipster中管理来自自定义REST的.json响应数据,javascript,angularjs,json,spring,rest,Javascript,Angularjs,Json,Spring,Rest,我正在Jhipster应用程序上创建一个新的定制RESTful web服务(用Spring框架管理),该应用程序搜索包含我在输入中给出的文本的对象请求 我测试了来自html和Angular.js的REST调用,效果很好。唯一的问题是,我不知道如何将结果解析为html页面而不是.json格式 调用REST的html代码(位于“src/main/webapp/app/layouts/navbar/navbar.html”)如下: <form class="navbar" method="GET

我正在Jhipster应用程序上创建一个新的定制RESTful web服务(用Spring框架管理),该应用程序搜索包含我在输入中给出的文本的对象请求

我测试了来自html和Angular.js的REST调用,效果很好。唯一的问题是,我不知道如何将结果解析为html页面而不是.json格式

调用REST的html代码(位于“src/main/webapp/app/layouts/navbar/navbar.html”)如下:

<form class="navbar" method="GET" action="/api/search">
    <input style="margin-top: 2.8%; margin-right:2px;" class="btn" type="text" name="content" placeholder="Search requests..." />
    <input style="margin-top: 2.8%; margin-right:5px;" class="btn btn-primary" type="submit" text="Search" value="Search">
</form>

我的java REST(RequestResource.java)如下所示:

所以,我的最后一个问题是:如何将.json对象列表转换为html表? 我在网上搜索了很多,但什么也没找到,我希望有人能帮我

谢谢你花时间给我提建议,
Manuel.

您可以在表单submit上调用函数,并在函数中的vm实例中获取json

HTML

    <form class="navbar" ng-submit="vm.getJson()">
            <input style="margin-top: 2.8%; margin-right:2px;" class="btn" type="text" name="content" ng-model="vm.content" placeholder="Search requests..." />
            <input style="margin-top: 2.8%; margin-right:5px;" class="btn btn-primary" type="submit" text="Search" value="Search">
        </form>
    <tr ng-repeat="value in json"><td>{{value }}</td></tr>

您可以在表单submit上调用函数,并在函数内的vm实例中获取json

HTML

    <form class="navbar" ng-submit="vm.getJson()">
            <input style="margin-top: 2.8%; margin-right:2px;" class="btn" type="text" name="content" ng-model="vm.content" placeholder="Search requests..." />
            <input style="margin-top: 2.8%; margin-right:5px;" class="btn btn-primary" type="submit" text="Search" value="Search">
        </form>
    <tr ng-repeat="value in json"><td>{{value }}</td></tr>

当您根据内容输入单击表单中的搜索值时,您会得到上面的json?当我单击按钮时,我会得到一个只显示该json字符串的空白页面。当您根据内容输入单击表单中的搜索值时,您会得到上面的json?当我单击按钮时,我会得到一个只显示该json的空白页面好的,这个引用是有效的。由于“所需的字符串参数'content'不存在”,我得到了代码500。我如何用angular给出它?你确定你的API是一个get方法吗?我认为您必须将搜索到的内容发送到API调用,并获得该场景的匹配结果。我正试图这样做:
$http.get(“/API/search?content=“+$scope.content”)。然后(函数(response){vm.json=response.data;console.log(response);})
在thml中,我在输入文本中添加了一个ng model=“content”,其中.js中的“content”是$scope.content,但问题是sameOk,我修复了它。我也必须注入$scope。非常感谢你的帮助,祝你度过愉快的一天!很高兴我能帮上忙。:)好的,参考资料有效。由于“所需的字符串参数'content'不存在”,我得到了代码500。我如何用angular给出它?你确定你的API是一个get方法吗?我认为您必须将搜索到的内容发送到API调用,并获得该场景的匹配结果。我正试图这样做:
$http.get(“/API/search?content=“+$scope.content”)。然后(函数(response){vm.json=response.data;console.log(response);})
在thml中,我在输入文本中添加了一个ng model=“content”,其中.js中的“content”是$scope.content,但问题是sameOk,我修复了它。我也必须注入$scope。非常感谢你的帮助,祝你度过愉快的一天!很高兴我能帮上忙。:)
[ {
  "id" : 13,
  "requestTitle" : "Titolo",
  "content" : "Richiesta",
  "creationDate" : "2017-06-23",
  "authorUsername" : "admin",
  "author" : null,
  "referencedTable" : {
    "id" : 3,
    "usersOnIt" : "",
    "name" : "Tavolo 1"
  }
}, {
  "id" : 14,
  "requestTitle" : "Voglio vedere Tiziano Ferro",
  "content" : "Mi piacerebbe vedere tiziano per fare ...",
  "creationDate" : "2017-06-25",
  "authorUsername" : "admin",
  "author" : null,
  "referencedTable" : {
    "id" : 4,
    "usersOnIt" : "alfa",
    "name" : "Tavolo 3"
  }
}, {
  "id" : 19,
  "requestTitle" : "Titolo",
  "content" : "Voglio vedere Marco",
  "creationDate" : "2017-06-26",
  "authorUsername" : "user",
  "author" : null,
  "referencedTable" : null
} ]
    <form class="navbar" ng-submit="vm.getJson()">
            <input style="margin-top: 2.8%; margin-right:2px;" class="btn" type="text" name="content" ng-model="vm.content" placeholder="Search requests..." />
            <input style="margin-top: 2.8%; margin-right:5px;" class="btn btn-primary" type="submit" text="Search" value="Search">
        </form>
    <tr ng-repeat="value in json"><td>{{value }}</td></tr>
vm.getJson=function(){
  $http.get("YourUrl",vm.content).then(function(response){
  vm.json=response.data;
 console.log(response);
})
}