{"id":2687,"date":"2013-04-04T10:00:46","date_gmt":"2013-04-04T07:00:46","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/?p=2687"},"modified":"2013-04-03T22:19:40","modified_gmt":"2013-04-03T19:19:40","slug":"spring-mvc-form-validation-with-annotations-2","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2013\/04\/spring-mvc-form-validation-with-annotations-2.html","title":{"rendered":"Spring MVC Form Validation (With Annotations)"},"content":{"rendered":"<p>This post provides a simple example of\u00a0a HTML form validation. It is based on the\u00a0<a href=\"http:\/\/tshikatshikaaa.blogspot.com\/2012\/08\/spring-mvc-with-annotations-example.html\" target=\"_blank\">Spring MVC With Annotations<\/a> example. The code is available on\u00a0<a href=\"https:\/\/github.com\/JVerstry\/Web-Related-Examples\" target=\"_blank\">GitHub<\/a> in the\u00a0Spring-MVC-Form-Validation directory.<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<\/p>\n<h2> Data<\/h2>\n<p>For this example we will use a bean and JSR303 validation annotations:<\/p>\n<pre class=\" brush:java\">public class MyUser {\r\n\r\n    @NotNull\r\n    @Size(min=1,max=20)\r\n    private String name;\r\n\r\n    @Min(0)\r\n    @Max(120)\r\n    private int age;\r\n\r\n    public MyUser(String name, int age) {\r\n        this.name = name;\r\n        this.age = age;\r\n    }\r\n\r\n    public MyUser() {\r\n        name = '';\r\n        age = 0;\r\n    }\r\n\r\n    \/\/ Setters &amp; Getters\r\n\r\n}<\/pre>\n<h2> Pages<\/h2>\n<p>Our form will contain input elements, but also the possibility to display error messages:<\/p>\n<pre class=\" brush:xml\">&lt;%@page contentType='text\/html' pageEncoding='UTF-8'%&gt;\r\n&lt;%@ taglib prefix='form' uri='http:\/\/www.springframework.org\/tags\/form' %&gt;\r\n&lt;!doctype html&gt;\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n  &lt;meta http-equiv='Content-Type' content='text\/html; charset=UTF-8'&gt;\r\n  &lt;title&gt;My User Form!&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n  &lt;form:form method='post' action='myForm' commandName='myUser'&gt;\r\n    &lt;table&gt;\r\n      &lt;tr&gt;\r\n        &lt;td&gt;Name: &lt;font color='red'&gt;&lt;form:errors path='name' \/&gt;&lt;\/font&gt;&lt;\/td&gt;\r\n      &lt;\/tr&gt;\r\n      &lt;tr&gt;\r\n        &lt;td&gt;&lt;form:input path='name' \/&gt;&lt;\/td&gt;\r\n      &lt;\/tr&gt;\r\n      &lt;tr&gt;\r\n        &lt;td&gt;Age: &lt;font color='red'&gt;&lt;form:errors path='age' \/&gt;&lt;\/font&gt;&lt;\/td&gt;\r\n      &lt;\/tr&gt;\r\n      &lt;tr&gt;\r\n        &lt;td&gt;&lt;form:input path='age' \/&gt;&lt;\/td&gt;\r\n      &lt;\/tr&gt;\r\n      &lt;tr&gt;\r\n        &lt;td&gt;&lt;input type='submit' value='Submit' \/&gt;&lt;\/td&gt;\r\n      &lt;\/tr&gt;\r\n    &lt;\/table&gt;\r\n  &lt;\/form:form&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<p>Our success page is:<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<pre class=\" brush:xml\">\r\n&lt;%@page contentType='text\/html' pageEncoding='UTF-8'%&gt;\r\n&lt;%@taglib prefix='form' uri='http:\/\/www.springframework.org\/tags\/form'%&gt;\r\n&lt;%@ taglib prefix='c' uri='http:\/\/java.sun.com\/jsp\/jstl\/core' %&gt;\r\n&lt;!doctype html&gt;\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n  &lt;meta http-equiv='Content-Type' content='text\/html; charset=UTF-8'&gt;\r\n  &lt;title&gt;Form Processed Successfully!&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n    Form processed for &lt;c:out value='${myUser.name}' \/&gt; ! &lt;br \/&gt;\r\n    &lt;a href='&lt;c:url value='\/'\/&gt;'&gt;Home&lt;\/a&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p>Our home page:<\/p>\n<pre class=\" brush:xml\">\r\n&lt;%@page contentType='text\/html' pageEncoding='UTF-8'%&gt;\r\n&lt;%@ taglib prefix='c' uri='http:\/\/java.sun.com\/jsp\/jstl\/core' %&gt;\r\n&lt;!doctype html&gt;\r\n&lt;html lang='en'&gt;\r\n&lt;head&gt;\r\n  &lt;meta charset='utf-8'&gt;\r\n  &lt;title&gt;Welcome !!!&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n  &lt;h1&gt;\r\n    Spring Form Validation !!!\r\n  &lt;\/h1&gt;\r\n&lt;a href='&lt;c:url value='\/myForm'\/&gt;'&gt;Go to the form!&lt;\/a&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<h2> Controller<\/h2>\n<p>Notice that we need to use <code>@ModelAttribute<\/code> to make sure an instance of <code>MyUser<\/code> is always available in the model. In the <code>validateForm()<\/code>, we need to use <code>@ModelAttribute<\/code> to move the content of the form to the MyUser project.<\/p>\n<pre class=\" brush:java\">@Controller\r\npublic class MyController {\r\n\r\n    @RequestMapping(value = '\/')\r\n    public String home() {\r\n        return 'index';\r\n    }\r\n\r\n    @ModelAttribute('myUser')\r\n    public MyUser getLoginForm() {\r\n        return new MyUser();\r\n    }\r\n\r\n    @RequestMapping(value = '\/myForm', method = RequestMethod.GET)\r\n    public String showForm(Map model) {\r\n        return 'myForm';\r\n    }\r\n\r\n    @RequestMapping(value = '\/myForm', method = RequestMethod.POST)\r\n    public String validateForm(\r\n        @ModelAttribute('myUser') @Valid MyUser myUser,\r\n        BindingResult result, Map model) {\r\n\r\n        if (result.hasErrors()) {\r\n            return 'myForm';\r\n        }\r\n\r\n        model.put('myUser', myUser);\r\n\r\n        return 'success';\r\n\r\n    }\r\n\r\n}<\/pre>\n<h2> Maven Dependencies<\/h2>\n<p>We need the following dependencies. The Hibernate validator dependency is necessary to process JSR303 annotations:<\/p>\n<pre class=\" brush:xml\">&lt;dependency&gt;\r\n  &lt;groupId&gt;javax.validation&lt;\/groupId&gt;\r\n  &lt;artifactId&gt;validation-api&lt;\/artifactId&gt;\r\n  &lt;version&gt;1.0.0.GA&lt;\/version&gt;\r\n  &lt;type&gt;jar&lt;\/type&gt;\r\n&lt;\/dependency&gt;\r\n\r\n&lt;dependency&gt;\r\n  &lt;groupId&gt;org.hibernate&lt;\/groupId&gt;\r\n  &lt;artifactId&gt;hibernate-validator&lt;\/artifactId&gt;\r\n  &lt;version&gt;4.3.0.Final&lt;\/version&gt;\r\n&lt;\/dependency&gt;<\/pre>\n<p><strong> Running The Example<\/strong><\/p>\n<p>Once compiled, the example can be run with<br \/>\nmvn tomcat:run. Then, browse:<\/p>\n<pre class=\"brush:bash\">\r\nhttp:\/\/localhost:8383\/\/spring-mvc-form-validation\/.\r\n<\/pre>\n<p>If the end user enters invalid values, error messages will be displayed:<\/p>\n<p><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/ErrMsg-1.jpg\"><img decoding=\"async\" class=\"alignnone size-medium wp-image-2689\" title=\"ErrMsg (1)\" alt=\"\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/ErrMsg-1-300x156.jpg\" width=\"300\" height=\"156\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/ErrMsg-1-300x156.jpg 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/ErrMsg-1.jpg 314w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\n&nbsp;<\/p>\n<p><strong><em>Reference: <\/em><\/strong><a href=\"http:\/\/tshikatshikaaa.blogspot.gr\/2012\/10\/spring-mvc-form-validation-with-annotations.html\">Spring MVC Form Validation (With Annotations)<\/a> from our <a href=\"http:\/\/www.javacodegeeks.com\/p\/jcg.html\">JCG partner<\/a> Jerome Versrynge at the <a href=\"http:\/\/tshikatshikaaa.blogspot.gr\/\">Technical Notes<\/a> blog.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This post provides a simple example of\u00a0a HTML form validation. It is based on the\u00a0Spring MVC With Annotations example. The code is available on\u00a0GitHub in the\u00a0Spring-MVC-Form-Validation directory. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Data For this example we will use a bean and JSR303 validation annotations: public class MyUser { @NotNull @Size(min=1,max=20) private &hellip;<\/p>\n","protected":false},"author":294,"featured_media":240,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[30,150],"class_list":["post-2687","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-spring","tag-spring-mvc"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Spring MVC Form Validation (With Annotations)<\/title>\n<meta name=\"description\" content=\"This post provides a simple example of\u00a0a HTML form validation. It is based on the\u00a0Spring MVC With Annotations example. The code is available on\u00a0GitHub in\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/2013\/04\/spring-mvc-form-validation-with-annotations-2.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Spring MVC Form Validation (With Annotations)\" \/>\n<meta property=\"og:description\" content=\"This post provides a simple example of\u00a0a HTML form validation. It is based on the\u00a0Spring MVC With Annotations example. The code is available on\u00a0GitHub in\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2013\/04\/spring-mvc-form-validation-with-annotations-2.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2013-04-04T07:00:46+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Jerome Versrynge\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jerome Versrynge\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/04\\\/spring-mvc-form-validation-with-annotations-2.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/04\\\/spring-mvc-form-validation-with-annotations-2.html\"},\"author\":{\"name\":\"Jerome Versrynge\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/658bd5fb8f00ed062406092ea069e948\"},\"headline\":\"Spring MVC Form Validation (With Annotations)\",\"datePublished\":\"2013-04-04T07:00:46+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/04\\\/spring-mvc-form-validation-with-annotations-2.html\"},\"wordCount\":180,\"commentCount\":3,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/04\\\/spring-mvc-form-validation-with-annotations-2.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"keywords\":[\"Spring\",\"Spring MVC\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/04\\\/spring-mvc-form-validation-with-annotations-2.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/04\\\/spring-mvc-form-validation-with-annotations-2.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/04\\\/spring-mvc-form-validation-with-annotations-2.html\",\"name\":\"Spring MVC Form Validation (With Annotations)\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/04\\\/spring-mvc-form-validation-with-annotations-2.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/04\\\/spring-mvc-form-validation-with-annotations-2.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"datePublished\":\"2013-04-04T07:00:46+00:00\",\"description\":\"This post provides a simple example of\u00a0a HTML form validation. It is based on the\u00a0Spring MVC With Annotations example. The code is available on\u00a0GitHub in\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/04\\\/spring-mvc-form-validation-with-annotations-2.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/04\\\/spring-mvc-form-validation-with-annotations-2.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/04\\\/spring-mvc-form-validation-with-annotations-2.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"width\":150,\"height\":150,\"caption\":\"spring-interview-questions-answers\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/04\\\/spring-mvc-form-validation-with-annotations-2.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\\\/enterprise-java\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Spring MVC Form Validation (With Annotations)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/658bd5fb8f00ed062406092ea069e948\",\"name\":\"Jerome Versrynge\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/90e571ae81f2c3c2cf7fc4f8b18e1fb8a294ca23d7fd6d066289696a31b2c774?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/90e571ae81f2c3c2cf7fc4f8b18e1fb8a294ca23d7fd6d066289696a31b2c774?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/90e571ae81f2c3c2cf7fc4f8b18e1fb8a294ca23d7fd6d066289696a31b2c774?s=96&d=mm&r=g\",\"caption\":\"Jerome Versrynge\"},\"sameAs\":[\"http:\\\/\\\/tshikatshikaaa.blogspot.com\\\/\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/Jerome-Versrynge\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Spring MVC Form Validation (With Annotations)","description":"This post provides a simple example of\u00a0a HTML form validation. It is based on the\u00a0Spring MVC With Annotations example. The code is available on\u00a0GitHub in","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/2013\/04\/spring-mvc-form-validation-with-annotations-2.html","og_locale":"en_US","og_type":"article","og_title":"Spring MVC Form Validation (With Annotations)","og_description":"This post provides a simple example of\u00a0a HTML form validation. It is based on the\u00a0Spring MVC With Annotations example. The code is available on\u00a0GitHub in","og_url":"https:\/\/www.javacodegeeks.com\/2013\/04\/spring-mvc-form-validation-with-annotations-2.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2013-04-04T07:00:46+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","type":"image\/jpeg"}],"author":"Jerome Versrynge","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Jerome Versrynge","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2013\/04\/spring-mvc-form-validation-with-annotations-2.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/04\/spring-mvc-form-validation-with-annotations-2.html"},"author":{"name":"Jerome Versrynge","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/658bd5fb8f00ed062406092ea069e948"},"headline":"Spring MVC Form Validation (With Annotations)","datePublished":"2013-04-04T07:00:46+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/04\/spring-mvc-form-validation-with-annotations-2.html"},"wordCount":180,"commentCount":3,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/04\/spring-mvc-form-validation-with-annotations-2.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","keywords":["Spring","Spring MVC"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2013\/04\/spring-mvc-form-validation-with-annotations-2.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2013\/04\/spring-mvc-form-validation-with-annotations-2.html","url":"https:\/\/www.javacodegeeks.com\/2013\/04\/spring-mvc-form-validation-with-annotations-2.html","name":"Spring MVC Form Validation (With Annotations)","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/04\/spring-mvc-form-validation-with-annotations-2.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/04\/spring-mvc-form-validation-with-annotations-2.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","datePublished":"2013-04-04T07:00:46+00:00","description":"This post provides a simple example of\u00a0a HTML form validation. It is based on the\u00a0Spring MVC With Annotations example. The code is available on\u00a0GitHub in","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/04\/spring-mvc-form-validation-with-annotations-2.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2013\/04\/spring-mvc-form-validation-with-annotations-2.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2013\/04\/spring-mvc-form-validation-with-annotations-2.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","width":150,"height":150,"caption":"spring-interview-questions-answers"},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2013\/04\/spring-mvc-form-validation-with-annotations-2.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/www.javacodegeeks.com\/category\/java"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/www.javacodegeeks.com\/category\/java\/enterprise-java"},{"@type":"ListItem","position":4,"name":"Spring MVC Form Validation (With Annotations)"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/658bd5fb8f00ed062406092ea069e948","name":"Jerome Versrynge","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/90e571ae81f2c3c2cf7fc4f8b18e1fb8a294ca23d7fd6d066289696a31b2c774?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/90e571ae81f2c3c2cf7fc4f8b18e1fb8a294ca23d7fd6d066289696a31b2c774?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/90e571ae81f2c3c2cf7fc4f8b18e1fb8a294ca23d7fd6d066289696a31b2c774?s=96&d=mm&r=g","caption":"Jerome Versrynge"},"sameAs":["http:\/\/tshikatshikaaa.blogspot.com\/"],"url":"https:\/\/www.javacodegeeks.com\/author\/Jerome-Versrynge"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/2687","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/294"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=2687"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/2687\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/240"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=2687"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=2687"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=2687"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}