BBSController { @GetMapping("bbs") public String bbs(HttpServletRequest request, @RequestParam(value = "problem_id", required = false) Long problemId, @RequestParam(value = "size", defaultValue = "50") final int threadLimit, @RequestParam(value = "top", defaultValue = "99999999") final long top, Model model) { int limit = Math.max(Math.min(threadLimit, 500), 0); final long mint = messageMapper.mint(top, problemId, limit, 0); final List<Message> messages = messageMapper.findAllByThreadIdBetween(mint, top, problemId, null); long currentDepth = 0; long lastThreadId = 0; model.addAttribute("title", "Messages"); StringBuilder sb = new StringBuilder("<table width=100% class=\"table-default table-back\">" + "<tr><td><ul>"); long maxThreadId = messages.stream().mapToLong(Message::getThread).max().orElse(0); final long maxt = messageMapper.maxt(maxThreadId, problemId, limit, 999999999999L); for (Message message : messages) { long depth = message.getDepth(); String title = message.getTitle(); String userId = message.getUser(); long messageId = message.getId(); Timestamp timestamp = Timestamp.from(message.getInDate()); long threadId = message.getThread(); Long problem = message.getProblem(); for (; currentDepth < depth; currentDepth++) { sb.append("<ul>"); } for (; currentDepth > depth; currentDepth--) { sb.append("</ul>"); } if (lastThreadId != 0 && threadId != lastThreadId && depth == 0) { sb.append("<hr/>"); } lastThreadId = threadId; sb.append("<li><a href=\"showmessage?message_id=").append(messageId) .append("\"><font color=\"blue\">") .append(HtmlEscape.escapeHtml4Xml(title)) .append("</font></a> <b><a href=\"userstatus?user_id=") .append(userId).append("\"><font color=\"black\">") .append(userId).append("</font></a></b> ") .append(timestamp); if (problem != null && problem != 0L && depth == 0) { sb.append(" <b><a href=\"showproblem?problem_id=").append(problem) .append("\"><font color=\"black\">Problem ").append(problem) .append("</font></a></b>"); } } for (; currentDepth > 0; currentDepth--) { sb.append("</ul>"); } sb.append("</ul></td></tr></table><center>"); URIBuilder query = URIBuilder.fromRequest(request) .replacePath("bbs") .replaceQueryParam("top"); sb.append("<hr/>[<a href=\"").append(query).append("\">Top</a>]"); query.replaceQueryParam("top", Long.toString(maxt)); sb.append("&nbsp;&nbsp;&nbsp;[<a href=\"").append(query).append("\">Previous</a>]"); query.replaceQueryParam("top", Long.toString(mint)); sb.append("&nbsp;&nbsp;&nbsp;[<a href=\"").append(query) .append("\">Next</a>]<br/></center><form action=\"postpage\">"); if (problemId != null) { sb.append("<input type=\"hidden\" name=\"problem_id\" value=\"").append(problemId).append("\">"); } sb.append("<button type=\"submit\">Post new message</button></form>"); model.addAttribute("content", sb.toString()); return "legacy"; }  @GetMapping("bbs") String bbs(HttpServletRequest request,
            @RequestParam(value = "problem_id", required = false) Long problemId,
            @RequestParam(value = "size", defaultValue = "50") final int threadLimit,
            @RequestParam(value = "top", defaultValue = "99999999") final long top,
            Model model); @Secured("ROLE_USER") @GetMapping({"postpage", "post"}) String postpage(Model model,
            @RequestParam(value = "problem_id", required = false) Long problemId); @PostMapping("post") @Secured("ROLE_USER") @Transactional String post(@RequestParam(value = "problem_id", required = false) Long problemId,
            @RequestParam(value = "parent_id", required = false) Long parentId,
            @RequestParam(value = "content", defaultValue = "") String content,
            @RequestParam(value = "title", defaultValue = "") String title,
            RedirectAttributes redirectAttributes,
            Authentication authentication); @Secured("ROLE_USER") @GetMapping("showmessage") String showMessage(
            @RequestParam("message_id") long messageId,
            Model model);  }
@Test public void testBbs() throws Exception { log.info("bbs"); Long problemId = null; int size = 50; long top = 99999999; MvcResult result = mvc.perform(get("/bbs") .param("problem_id", Objects.toString(problemId, "")) .param("size", Integer.toString(size)) .param("top", Long.toString(top))) .andExpect(status().isOk()) .andExpect(content().contentTypeCompatibleWith(MediaType.TEXT_HTML)) .andReturn(); }