-
在admin.html页面中 创建vue对象管理header标签,并在created里面请求当前登录的用户对象,在methods里面声明logout方法
<script>
let header_vm = new Vue({
el:"header",
data:{
user:{}
},
created:function () {
//发请求得到当前登录的用户对象
axios.get("/currentuser").then(function (response) {
//代表没有登录
if (response.data==""){
alert("请先登录!");
location.href="/login.html";
}
header_vm.user = response.data;
})
},
methods: {
logout:function () {
if (!confirm("您确认退出登录吗?")){
return;
}
//发出退出登录请求
axios.get("/logout").then(function () {
//显示到首页
location.href="/index.html";
})
}
}
})
</script> -
UserController里面处理获取当前用户的请求 和 退出登录请求
-
在header标签里面绑定vue相关标签
发布作品功能
-
建表:
use vrddb;
create table product(id int primary key auto_increment,title varchar(50),author varchar(50),url varchar(255),view_count int,like_count int,created timestamp,category_id int)charset=utf8;
alter table product add intro varchar(255) after author; -
-
创建ProductMapper 里面提供insert方法