「Spring」@ModelAttributeとform:inputタグを利用するサンプル

Javaコード

    @RequestMapping(value = "/userRegist", method = RequestMethod.POST)
    public String userRegist(
            @Valid @ModelAttribute("userModel") UserModel userModel,
            Errors errors) {
        if (errors.hasErrors()) {
            return "xxx";
        }
		//some code
        return "xxx";
    }

JSPコード

<form:form modelAttribute="userModel" action="userRegist" method="post">
  <form:errors path="*" element="div" />
  <form:label path="username">uasername:</form:label><form:input path="username" size="20" /><br>
     //some code
</form:form>

 

Software

Posted by arkgame