我是spring-data-rest的新手。在我的应用程序中,当我进行一次休息呼叫时,我得到的json包含自我链接和与外键表的链接。但是我想用json代替链接。我使用telosys工具生成器生成了代码。这是我对数据库中的“商品”表进行REST调用时所得到的JSON:
{
"id" : 1,
"rate": 300,
"type": "item",
"shortDescription": "test",
"longDescription": "test test",
"_links": {
"self": {
"href": "http://localhost:8080/sportsrest/merchandises/1"
},
"listOfMerchandiseAttribute": {
"href": "http://localhost:8080/sportsrest/merchandises/1/listOfMerchandiseAttribute"
},
}
}
Run Code Online (Sandbox Code Playgroud)
但是,我不是要获取“ listOfMerchandiseAttribute”的链接,而是要获取listOfMerchandiseAttribute的JSON。listOfMerchandiseAttribute是我数据库中的另一个表
那就是我想要这样的json:
{
"id": 1,
"rate": 300,
"type": "item",
"shortDescription": "test",
"longDescription": "test test",
"_links": {
"self": {
"href": "http://localhost:8080/sportsrest/merchandises/1"
},
"listOfMerchandiseAttribute": {
"id": 1,
"attributeName": "testname",
"attributeValue": 50
},
}
}
Run Code Online (Sandbox Code Playgroud)
当我在google上搜索时,我得到了一些结果,并根据该结果更改了ApplicationConfig.java文件,但仍在获取链接而不是JSON。这是我的ApplicationConfig文件。
ApplicationConfig.java
/*
* Created on 19 Mar 2015 ( Time 14:41:07 )
* Generated by Telosys Tools Generator …Run Code Online (Sandbox Code Playgroud) 我是 Node.js 的新手,我正在使用 Node.js、HTML、CSS、JS 设计一个基本网站。
在我的应用程序中在本地服务器上调用 localhost:4000/ 后,我可以访问主页。在我的主页上有一个“联系我们”选项卡。当我点击它时,它应该重定向到 contactus.html 页面。但是当我在服务器上运行它时,它显示无法获取/contactus.html。
这是我的服务器:
var fs=require('fs');
var express=require('express');
var app=express();
app.use(express.static(__dirname + '/static'));
app.get('/', function(req,res) {
data= fs.readFile('/home/swift-03/WebstormProjects/website/static/HTML/home.html', function (err, data) {
res.setHeader('Content-Type', 'text/html');
res.send(data);
});
});
app.listen(4000);
Run Code Online (Sandbox Code Playgroud)
我的 Html 页面是:
<!DOCTYPE html>
<html>
<head>
<script>
function contactus() {
document.location="contactus.html";
}
</script>
</head>
<body>
<div class="pos_right">
<ul class="div">
<li><a href="#" onclick="contactus()">Contact</a></li>
</ul>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
这是我的目录结构:

提前致谢!!!