做毕设(三)——用户界面

兴致很高,趁着劲头把用户界面也做起来

<body align="center">
    <h3 th:text="${Username}">用户名</h3>
    <hr/>
    <div th:each="cs:${Comments}">
        <p th:text="${cs.comtime}">时间</p>
        <p th:utext="${cs.nid}">新闻</p>
        <p th:utext="${cs.context}">内容</p>
    </div>
</body>

很简陋,只有评论。

@RequestMapping(value = "/{id}",method = RequestMethod.GET)
    public String toUserById(@PathVariable("id") String id,ModelMap map){
        map.addAttribute("Username",userService.getUsernameById(Integer.valueOf(id)));
        List<Comment> comments = commentService.getAllCommentByUid((id));
        Collections.reverse(comments);

        for(int i=0;i<comments.size();i++){
            int nid = Integer.valueOf(comments.get(i).getNid());
            String titleWithUrl = "<a href =\"../" + nid + "\">" + newsService.getNewsTitleById(nid) + "</a>";
            comments.get(i).setNid(titleWithUrl);
            //判断是否是回复,做出处理
            String tid = comments.get(i).getTid();
            if(tid == null || tid == "") {
                //什么都不做
            }else {
                String tName = userService.getUsernameById(Integer.valueOf(comments.get(i).getTid()));
                comments.get(i).setContext("回复<a href =\"../user/" + tid + "\">@" + tName + "</a> :" + comments.get(i).getContext());
            }
        }
        map.addAttribute("Comments",comments);

        return "user";
    }

好臃肿的代码……
把超链接直接写到属性里传过去了。
同理把新闻的Conrtoller也修改下。

comments.get(i).setUid("<a href =\"user/" + uid + "\">" + uName + "</a> :");
comments.get(i).setTid("回复<a href =\"user/" + tid + "\">@" + tName + "</a> :");

感觉接下来只有各种增删改查了呢:)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值