我想知道使用起来是否多余
consumes
和procudes
与bindingMode
吗?
rest()
.description("rest service provider")
.consumes("application/xml").produces("application/xml")
.post("/start").type(P.class)
.bindingMode(RestBindingMode.json_xml)
.description("Service to start a test process")
.route().routeId("REST").log("Message send: \n ${body}")
我应该只使用其中一行吗?有什么区别?
.consumes("application/xml").produces("application/xml")
.bindingMode(RestBindingMode.json_xml)
答案 0 :(得分:0)
您可以在 restConfiguration 上使用 .bindingMode 来向或从POJO出价xml / json。 然后在其余的VERB操作中使用 .consume 或 .produces 来指定要接收的类型或生产。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Test</title>
<style>
</style>
<script>
function makeI(myId, myA) {
var I = {
id: myId,
A: myA,
toString: function toString() { console.log('id:' +I.id+ ', A=' +this.A); return this;},
// ^ ^
// | |
// What's better, more clear? shorter how does this help, just fools us on callbacks?
//
oops: function oops() {
document.getElementById('div').onclick = function()
{ console.log('oops() A=' +this.A+ ' , darn! Well, the id=' +this.id+ " , NOT our/I's id"); }
},
f: function f() {
document.getElementById('div').onclick = function()
{ console.log('oops() A=' +I.A+ ' , good. Well, the id=' +I.id); }
},
}
return I;
}
function try1() {
console.log('---- try1() , my oops ---------');
var i1 = makeI('1', 10).toString();
i1.oops();
console.log('OK, now please click on gold div, and watch the error\n');
}
function try2() {
console.log('---- try2() ---------');
var i2 = makeI('2', 20).toString();
i2.f();
console.log('OK, now please click on gold div\n');
}
</script>
</head>
<body>
<div onclick='try1()' style='border: 2px solid red; width:400px;'>Please click, and see console output (oops!)</div><br>
<div onclick='try2()' style='border: 2px solid green; width:400px;'>Please click, and see console output, comments please</div><br>
<div id='div' style='border: 2px solid gold; width:400px;'>div</div>
</body>
</html>