Bean Validation - Modify Article

BbsController.java
@RequestMapping(value="/modify", method=RequestMethod.GET)
public String modifyForm(Integer articleNo, String boardCd, Model model) {
  
  Article article = boardService.getArticle(articleNo);
  String boardNm = boardService.getBoardNm(article.getBoardCd());

  model.addAttribute("article", article);
  model.addAttribute("boardNm", boardNm);
  
  return "bbs/modify";
}

@RequestMapping(value="/modify", method=RequestMethod.POST)
public String modify(@Valid Article article, BindingResult bindingResult,
    Integer page,
    String searchWord,
    Model model,
    MultipartHttpServletRequest mpRequest) throws Exception {

  if (bindingResult.hasErrors()) {
    String boardNm = boardService.getBoardNm(article.getBoardCd());
    model.addAttribute("boardNm", boardNm);
    return "bbs/modify";
  }

  String email = boardService.getArticle(article.getArticleNo()).getEmail();
  article.setEmail(email);

  boardService.modifyArticle(article);

  //..omit..

  //Modified setArticleNo(articleNo) to setArticleNo(article.getArticleNo()) in file information insert code

  searchWord = URLEncoder.encode(searchWord, "UTF-8");
    
  return "redirect:/bbs/view?articleNo=" + article.getArticleNo() +
    "&boardCd=" + article.getBoardCd() +
    "&page=" + page +
    "&searchWord=" + searchWord
}
modify.jsp
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="sf" %>

<sf:form id="modifyForm" action="modify" method="post" modelAttribute="article"
        enctype="multipart/form-data" onsubmit="return check()">
<input type="hidden" name="articleNo" value="${param.articleNo }" />
<input type="hidden" name="boardCd" value="${param.boardCd }" />
<input type="hidden" name="page" value="${param.page }" />
<input type="hidden" name="searchWord" value="${param.searchWord }" />
<sf:errors path="*" cssClass="error" />
<table id="write-form">
<tr>
  <td>Title</td>
  <td>
    <sf:input path="title" style="width: 90%" /><br />
    <sf:errors path="title" cssClass="error" />
  </td>
</tr>
<tr>
  <td colspan="2">
    <sf:textarea path="content" rows="17" cols="50" /><br />
    <sf:errors path="content" cssClass="error" />
  </td>
</tr>
<tr>
  <td>Attach File</td>
  <td><input type="file" name="attachFile" /></td>
</tr>
</table>
<div style="text-align: center;padding-bottom: 15px;">
  <input type="submit" value="Submit" />
  <input type="button" value="Detailed view" onclick="goView()" />
</div>
</sf:form>

On the post edit screen, clear all the input fields and click the Submit button.

Modify article test 1

Modify article test 2

References