导航栏用户模块设计(个人博客)

导航栏用户模块设计(个人博客)

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

一、修改前端页面

利用sec:authorize="isAuthenticated()"实现

    <div class="right m-item m-mobile-hide menu" sec:authorize="isAuthenticated()">
        <div class="ui dropdown item">
            <div class="text"><img class="ui avatar image" src="https://picsum.photos/50/50?image=1005">
                <span sec:authentication="principal.username"></span>
            </div>
            <i class="dropdown icon"></i>
            <div class="menu">
                <a th:href="@{/logout}" class="item">注销</a>
                <a th:href="@{/toUpdUser}" class="item">修改密码</a>
            </div>
        </div>
    </div>

  <h5 style="margin-top: 18px;color: skyblue" sec:authorize="!isAuthenticated()"><a th:href="@{/toLogin}">登录</a></h5>

二、用户信息修改功能实现

1、编写dao层
2、绑定mapper配置文件
3、编写service层
4、编写controller层
@RequestMapping("/toUpdUser")
public String toUpdateUser(Principal principal, Model model){
    User user = userService.getByName(principal.getName());
    model.addAttribute("user",user);
    return "admin/users-update";
}

@RequestMapping("/admin/updUser")
public String updUser(User user){
    userService.updateUser(user);
    return "redirect:/logout";
}
5、绑定前端页面
<form th:action="@{/admin/updUser}" method="post" class="ui segment form">
    <input type="hidden" name="id" th:value="${user.id}">
    <input type="hidden" name="username" th:value="${user.username}">
    <div class="field">
        <label>用户名</label>
        <input type="text" name="nickname" th:placeholder="${user.nickname}" th:value="${user.nickname}">
    </div>
    <div class="field">
        <label>密码</label>
        <input type="text" name="password" th:placeholder="${user.password}" th:value="${user.password}">
    </div>
    <div class="field">
        <label>头像链接</label>
        <input type="text" name="avatar" th:placeholder="${user.avatar}" th:value="${user.avatar}">
    </div>
    <div class="field">
        <button class="ui teal basic mini button"><i class="search icon"></i>确认</button>
    </div>
</form>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值