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

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

<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 comments = commentService.getAllCommentByUid((id));
        Collections.reverse(comments);

        for(int i=0;i
            int nid = Integer.valueOf(comments.get(i).getNid());
            String titleWithUrl = " + nid + "\">" + newsService.getNewsTitleById(nid) + "";
            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("回复 + tid + "\">@" + tName + " :" + comments.get(i).getContext());
            }
        }
        map.addAttribute("Comments",comments);

        return "user";
    }

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

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

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

你可能感兴趣的:(毕设论文)