67,515
社区成员
发帖
与我相关
我的任务
分享
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script type="text/javascript" src="static/jquery-2.0.0.js"></script>
<style type="text/css">
ul{list-style: none; border: 1px solid #ccc; width: 300px;}
</style>
</head>
<body>
<input type="text">
<ul class="console">
</ul>
</body>
<script type="text/javascript">
$('input').on('keydown', function(e) {
if (e.which != 13)
{
return;
}
var _this = this;
if (_this.value)
{
$.get('http://www.bree.cn/job/hello', {key: _this.value}).then(function(msg) {
_this.value = '';
$('.console').prepend('<li>'.concat(msg, '</li>'));
});
}
});
</script>
</html>
后台
@RestController
public class DefaultController {
@RequestMapping("/hello")
public String hello(String key) {
return "hello " + key;
}
}