{"id":18414,"date":"2013-10-26T15:00:19","date_gmt":"2013-10-26T12:00:19","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/?p=18414"},"modified":"2013-10-25T08:59:36","modified_gmt":"2013-10-25T05:59:36","slug":"exploring-spring-controller-with-jstl-view","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2013\/10\/exploring-spring-controller-with-jstl-view.html","title":{"rendered":"Exploring Spring Controller with JSTL view"},"content":{"rendered":"<p>Let\u2019s improve <a href=\"http:\/\/www.javacodegeeks.com\/2013\/10\/getting-started-with-spring-jdbc-in-a-web-application.html\">our previous Spring JDBC application<\/a> with some more exploration on Spring MVC\u2019s Controller development. I will show another exercise of writing a new Controller that processes a HTML form and use JSTL tags in JSP view pages.<\/p>\n<p>To enable JSTL in Spring MVC application, you would need to add the following to the <code>WebAppConfig<\/code> config class. Let\u2019s move it outside of <code>WebApp.java<\/code> and into it\u2019s own top level class file in <code>src\/main\/java\/springweb\/WebAppConfig.java<\/code>.<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<\/p>\n<pre class=\" brush:java\">package springweb;\r\n\r\nimport org.springframework.context.annotation.Bean;\r\nimport org.springframework.context.annotation.ComponentScan;\r\nimport org.springframework.context.annotation.Configuration;\r\nimport org.springframework.web.servlet.config.annotation.EnableWebMvc;\r\nimport org.springframework.web.servlet.view.InternalResourceViewResolver;\r\n\r\n@Configuration\r\n@EnableWebMvc\r\n@ComponentScan(\"springweb.controller\")\r\npublic class WebAppConfig {\r\n    @Bean\r\n    public InternalResourceViewResolver viewResolver() {\r\n        InternalResourceViewResolver result = new InternalResourceViewResolver();\r\n        result.setPrefix(\"\/\");\r\n        result.setSuffix(\".jsp\");\r\n        return result;\r\n    }\r\n}<\/pre>\n<p>Inside the <code>InternalResourceViewResolver<\/code> bean, you define where to find your JSP pages that may have JSTL tags in them. The <code>prefix<\/code> setter is a path in relative to your <code>src\/webapp<\/code> location. This allow you to hide your JSP files completely if you want to. For example, by setting it to <code>\"\/WEB-INF\/jsp\"<\/code> then you may move and store all JSP files into <code>src\/webapp\/WEB-INF\/jsp<\/code> which is private in the web application. The <code>suffix<\/code> is just the file extension. These two values allow you to return a view name inside the controller with just the basename of your JSP file, which can be short as &#8220;\/myform&#8221; or &#8220;\/index&#8221; etc.<\/p>\n<p>If you are to use Tomcat as your web container, you would need to add JSTL jar dependency as well, since the Tomcat server doesn\u2019t come with standard tag library! So add this into the <code>pom.xml<\/code> file now.<\/p>\n<pre class=\" brush:xml\">&lt;dependency&gt;\r\n            &lt;groupId&gt;javax.servlet&lt;\/groupId&gt;\r\n            &lt;artifactId&gt;jstl&lt;\/artifactId&gt;\r\n            &lt;version&gt;1.2&lt;\/version&gt;\r\n        &lt;\/dependency&gt;<\/pre>\n<p>While you\u2019re at the <code>pom.xml<\/code> file, you might want to add the Tomcat maven plugin so you can type less in command line when running your web application.<\/p>\n<pre class=\" brush:xml\">&lt;project&gt;\r\n...\r\n    &lt;build&gt;\r\n        &lt;plugins&gt;\r\n            &lt;plugin&gt;\r\n                &lt;groupId&gt;org.apache.tomcat.maven&lt;\/groupId&gt;\r\n                &lt;artifactId&gt;tomcat7-maven-plugin&lt;\/artifactId&gt;\r\n                &lt;version&gt;2.1&lt;\/version&gt;\r\n            &lt;\/plugin&gt;\r\n        &lt;\/plugins&gt;\r\n    &lt;\/build&gt;\r\n...\r\n&lt;\/project&gt;<\/pre>\n<p>With that, you should able to run <code>mvn tomcat7:run<\/code> in root of your project without plugin prefix.<\/p>\n<p>So what does JSTL bring to your application? Well, quite a bit actually. It lets you use some standard JSP tags that\u2019s frequently used when writing JSP views. I will demonstrate this with a set of Controller and views to capture user comments from the application. Note that I will try to show you how to work with Spring Controller in the most basic way only. The Spring actually comes with a custom <code>form<\/code> JSP tag that is much more powerful to use. I will reserve that as another article in another time. Today let us focus on learning more about basic Spring Controller and JSTL, and a bit more on Spring JDBC data service as well.<\/p>\n<p>We want to capture user comment, so let\u2019s add a database table to store that information. Add the following DDL into your <code>src\/main\/resources\/schema.sql<\/code> file. Again, this is for H2 database per last article project setup.<\/p>\n<pre class=\" brush:java\">CREATE TABLE COMMENT (\r\n  ID INT NOT NULL PRIMARY KEY AUTO_INCREMENT,\r\n  TEXT VARCHAR(10240) NOT NULL,\r\n  FROM_USER VARCHAR(15) NULL,\r\n  FROM_USER_IP VARCHAR(15) NULL,\r\n  FROM_URL VARCHAR(1024) NULL,\r\n  TAG VARCHAR(1024) NULL,\r\n  TS DATETIME NOT NULL\r\n);<\/pre>\n<p>This time, we will write a data model class to match this table. Let\u2019s add <code>src\/main\/java\/springweb\/data\/Comment.java<\/code><\/p>\n<pre class=\" brush:java\">package springweb.data;\r\n\r\nimport java.util.Date;\r\n\r\npublic class Comment {\r\n    Long id;\r\n    String text;\r\n    String fromUrl;\r\n    String fromUser;\r\n    String fromUserIp;\r\n    String tag;\r\n    Date ts;\r\n\r\n    public Long getId() {\r\n        return id;\r\n    }\r\n\r\n    public void setId(Long id) {\r\n        this.id = id;\r\n    }\r\n\r\n    public String getText() {\r\n        return text;\r\n    }\r\n\r\n    public void setText(String text) {\r\n        this.text = text;\r\n    }\r\n\r\n    public String getFromUrl() {\r\n        return fromUrl;\r\n    }\r\n\r\n    public void setFromUrl(String fromUrl) {\r\n        this.fromUrl = fromUrl;\r\n    }\r\n\r\n    public String getFromUser() {\r\n        return fromUser;\r\n    }\r\n\r\n    public void setFromUser(String fromUser) {\r\n        this.fromUser = fromUser;\r\n    }\r\n\r\n    public String getFromUserIp() {\r\n        return fromUserIp;\r\n    }\r\n\r\n    public void setFromUserIp(String fromUserIp) {\r\n        this.fromUserIp = fromUserIp;\r\n    }\r\n\r\n    public String getTag() {\r\n        return tag;\r\n    }\r\n\r\n    public void setTag(String tag) {\r\n        this.tag = tag;\r\n    }\r\n\r\n    public Date getTs() {\r\n        return ts;\r\n    }\r\n\r\n    public void setTs(Date ts) {\r\n        this.ts = ts;\r\n    }\r\n\r\n    private String getTrimedComment(int maxLen) {\r\n        if (text == null)\r\n            return null;\r\n        if (text.length() &lt;= maxLen)\r\n            return text;\r\n        return text.substring(0, maxLen);\r\n    }\r\n\r\n    @Override\r\n    public String toString() {\r\n        return \"Comment{\" +\r\n                \"id=\" + id +\r\n                \", ts=\" + ts +\r\n                \", text='\" + getTrimedComment(12) + '\\'' +\r\n                '}';\r\n    }\r\n\r\n    public static Comment create(String commentText) {\r\n        Comment result = new Comment();\r\n        result.setText(commentText);\r\n        result.setTs(new Date());\r\n        return result;\r\n    }\r\n}<\/pre>\n<p>Just as previous artcicle, we will write a data service to handle insert and retrieve of the data model. We add a new <code>src\/main\/java\/springweb\/data\/CommentService.java<\/code> file<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:java\">package springweb.data;\r\n\r\nimport org.apache.commons.logging.Log;\r\nimport org.apache.commons.logging.LogFactory;\r\nimport org.springframework.beans.factory.annotation.Autowired;\r\nimport org.springframework.jdbc.core.BeanPropertyRowMapper;\r\nimport org.springframework.jdbc.core.JdbcTemplate;\r\nimport org.springframework.jdbc.core.RowMapper;\r\nimport org.springframework.jdbc.core.simple.SimpleJdbcInsert;\r\nimport org.springframework.stereotype.Repository;\r\n\r\nimport javax.sql.DataSource;\r\nimport java.util.HashMap;\r\nimport java.util.List;\r\nimport java.util.Map;\r\n\r\n@Repository\r\npublic class CommentService {\r\n    public static Log LOG = LogFactory.getLog(CommentService.class);\r\n\r\n    private JdbcTemplate jdbcTemplate;\r\n    private SimpleJdbcInsert insertActor;\r\n    private RowMapper&lt;Comment&gt; commentBeanRowMapper = new BeanPropertyRowMapper&lt;Comment&gt;(Comment.class);\r\n\r\n    @Autowired\r\n    public void setDataSource(DataSource dataSource) {\r\n        this.jdbcTemplate = new JdbcTemplate(dataSource);\r\n        this.insertActor = new SimpleJdbcInsert(dataSource)\r\n            .withTableName(\"COMMENT\")\r\n            .usingGeneratedKeyColumns(\"ID\");\r\n    }\r\n\r\n    public void insert(Comment comment) {\r\n        LOG.info(\"Inserting Comment + \" + comment);\r\n\r\n        Map&lt;String, Object&gt; parameters = new HashMap&lt;String, Object&gt;(2);\r\n        parameters.put(\"TEXT\", comment.getText());\r\n        parameters.put(\"FROM_USER\", comment.getFromUser());\r\n        parameters.put(\"FROM_USER_IP\", comment.getFromUserIp());\r\n        parameters.put(\"FROM_URL\", comment.getFromUrl());\r\n        parameters.put(\"TAG\", comment.getTag());\r\n        parameters.put(\"TS\", comment.getTs());\r\n        Number newId = insertActor.executeAndReturnKey(parameters);\r\n        comment.setId(newId.longValue());\r\n\r\n        LOG.info(\"New Comment inserted. Id=\" + comment.getId());\r\n    }\r\n\r\n    public List&lt;Comment&gt; findComments() {\r\n        String sql = \"SELECT \" +\r\n                \"ID as id, \" +\r\n                \"TEXT as text, \" +\r\n                \"TAG as tag, \" +\r\n                \"TS as ts, \" +\r\n                \"FROM_USER as fromUser, \" +\r\n                \"FROM_USER_IP as fromUserIp, \" +\r\n                \"FROM_URL as fromUrl \" +\r\n                \"FROM COMMENT ORDER BY TS\";\r\n        List&lt;Comment&gt; result = jdbcTemplate.query(sql, commentBeanRowMapper);\r\n        LOG.info(\"Found \" + result.size() + \" Comment records.\");\r\n        return result;\r\n    }\r\n}<\/pre>\n<p>Since we did not use any fancy ORM but just plain JDBC, we will have to write SQL in the data service. But thanks to Spring goodies, it makes life much easier with helpers such as <code>SimpleJdbcInsert<\/code>, which handles DB insert and retrieval of auto generated key etc. And also notice that in query, we use the Spring\u2019s <code>BeanPropertyRowMapper<\/code> to automatically convert JDBC resultset into a java bean <code>Comment<\/code> object! Simple, direct and quick.<\/p>\n<p>Now we add the Spring controller in <code>src\/main\/java\/springweb\/controller\/CommentController.java<\/code> to handle web requests.<\/p>\n<pre class=\" brush:java\">package springweb.controller;\r\n\r\nimport org.springframework.beans.factory.annotation.Autowired;\r\nimport org.springframework.stereotype.Controller;\r\nimport org.springframework.web.bind.annotation.RequestMapping;\r\nimport org.springframework.web.bind.annotation.RequestMethod;\r\nimport org.springframework.web.bind.annotation.RequestParam;\r\nimport org.springframework.web.servlet.ModelAndView;\r\nimport springweb.data.Comment;\r\nimport springweb.data.CommentService;\r\n\r\nimport javax.servlet.http.HttpServletRequest;\r\nimport java.util.List;\r\n\r\n@Controller\r\npublic class CommentController {\r\n\r\n    @Autowired\r\n    private CommentService commentService;\r\n\r\n    @RequestMapping(value=\"\/comments\")\r\n    public ModelAndView comments() {\r\n        List&lt;Comment&gt; comments = commentService.findComments();\r\n        ModelAndView result = new ModelAndView(\"\/comments\");\r\n        result.addObject(\"comments\", comments);\r\n        return result;\r\n    }\r\n\r\n    @RequestMapping(value=\"\/comment\")\r\n    public String comment() {\r\n        return \"comment\";\r\n    }\r\n\r\n    @RequestMapping(value=\"\/comment\", method = RequestMethod.POST)\r\n    public ModelAndView postComment(HttpServletRequest req, @RequestParam String commentText) {\r\n        String fromUrl = req.getRequestURI();\r\n        String user = req.getRemoteUser();\r\n        String userIp = req.getRemoteAddr();\r\n        Comment comment = Comment.create(commentText);\r\n        comment.setFromUserIp(userIp);\r\n        comment.setFromUser(user);\r\n        comment.setFromUrl(fromUrl);\r\n        commentService.insert(comment);\r\n        ModelAndView result = new ModelAndView(\"comment-posted\");\r\n        result.addObject(\"comment\", comment);\r\n        return result;\r\n    }\r\n}<\/pre>\n<p>In this controller we map <code>\/comment<\/code> URL to handle display of the HTML form, which returns the <code>comment.jsp<\/code> view. The method default to handle a HTTP <code>GET<\/code>. Note that we remapped same <code>\/comment<\/code> URL to handle HTTP <code>POST<\/code> on a separated <code>postComment()<\/code> method! See how clean the Spring Controller can be in this demo to handle HTTP request. Pay very close attention to the parameters declared in the <code>postComment()<\/code> method. Spring automatically handles the HTTP request object and map to your method just based upon the types you declared! On some cases you need to be explicit with the help of annotation such as <code>@RequestParam<\/code>, but Spring does the parsing of HTTP request and extraction for you! This saves you tons of repeated boiler plate code if we were to write a direct Servlet code.<\/p>\n<p>Now let\u2019s see the view and how to use JSTL. The <code>\/comments<\/code> URL is mapped to <code>src\/main\/webapp\/comments.jsp<\/code> view file, which will list all <code>Comment<\/code> model objects.<\/p>\n<pre class=\" brush:xml\">&lt;%@ taglib prefix=\"c\" uri=\"http:\/\/java.sun.com\/jsp\/jstl\/core\" %&gt;\r\n&lt;c:choose&gt;\r\n&lt;c:when test=\"${empty comments}\"&gt;\r\n    &lt;p&gt;There are no comments in system yet.&lt;\/p&gt;\r\n&lt;\/c:when&gt;\r\n&lt;c:otherwise&gt;\r\n    &lt;table border=\"1\"&gt;\r\n    &lt;tr&gt;\r\n        &lt;td&gt;INDEX&lt;\/td&gt;\r\n        &lt;td&gt;TIME&lt;\/td&gt;\r\n        &lt;td&gt;FROM&lt;\/td&gt;\r\n        &lt;td&gt;COMMENT&lt;\/td&gt;\r\n    &lt;\/tr&gt;\r\n    &lt;c:forEach items=\"${comments}\" var=\"comment\" varStatus=\"status\"&gt;\r\n    &lt;tr valign=\"top\"&gt;\r\n        &lt;td&gt;${status.index}&lt;\/td&gt;\r\n        &lt;td&gt;${comment.ts}&lt;\/td&gt;\r\n        &lt;td&gt;${comment.fromUserIp}&lt;\/td&gt;\r\n        &lt;%-- The c:out will escape html\/xml characters. --%&gt;\r\n        &lt;td&gt;&lt;pre&gt;&lt;c:out value=\"${comment.text}\"\/&gt;&lt;\/pre&gt;&lt;\/td&gt;\r\n    &lt;\/tr&gt;\r\n    &lt;\/c:forEach&gt;\r\n    &lt;\/table&gt;\r\n&lt;\/c:otherwise&gt;\r\n&lt;\/c:choose&gt;<\/pre>\n<p>Pretty standard stuff on JSTL. Next is the HTML form to post comment in <code>src\/main\/webapp\/comment.jsp<\/code> file.<\/p>\n<pre class=\" brush:xml\">&lt;form action=\"comment\" method=\"POST\"&gt;\r\n&lt;textarea name=\"commentText\" rows=\"20\" cols=\"80\"&gt;&lt;\/textarea&gt;\r\n&lt;br\/&gt;\r\n&lt;input type=\"submit\" value=\"Post\"\/&gt;\r\n&lt;\/form&gt;<\/pre>\n<p>When form is posted and processed successful, we simply return to a new page in <code>src\/main\/webapp\/comment-posted.jsp<\/code> file as output.<\/p>\n<pre class=\" brush:xml\">&lt;p&gt;Your comment has been posted. Comment ID=${comment.id}&lt;\/p&gt;<\/pre>\n<p>If you&#8217;ve done these right, you should able to run <code>mvn tomcat7:run<\/code> and browse <code>http:\/\/localhost:8080\/spring-web-annotation\/comment<\/code> to see the form. Go to <code>\/comments<\/code> URL to verify all the comments posted.<\/p>\n<p>Note that despite I used Spring Controller as backend, all the views are in basic JSTL, and even the form are just basic HTML elements! I did this so you can see how flexible Spring Controller can be.<\/p>\n<p>I know these are lot of code to post as a blog article today, but I wanted to be complete and try to show a working demo with tutorial notes. I choose to make it into a single post with file content instead of having you download a project somewhere else. It makes my notes and explanation easier to match onto the code.<\/p>\n<p>And that will conclude our tutorial for today. Please leave a note if you find this helpful.<br \/>\n&nbsp;<\/p>\n<div style=\"border: 1px solid #D8D8D8; background: #FAFAFA; width: 100%; padding-left: 5px;\"><b><i>Reference: <\/i><\/b><a href=\"http:\/\/saltnlight5.blogspot.com\/2013\/10\/exploring-spring-controller-with-jstl.html\">Exploring Spring Controller with JSTL view<\/a> from our <a href=\"http:\/\/www.javacodegeeks.com\/jcg\">JCG partner<\/a> Zemian Deng at the <a href=\"http:\/\/saltnlight5.blogspot.com\/\">A Programmer&#8217;s Journal<\/a> blog.<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Let\u2019s improve our previous Spring JDBC application with some more exploration on Spring MVC\u2019s Controller development. I will show another exercise of writing a new Controller that processes a HTML form and use JSTL tags in JSP view pages. To enable JSTL in Spring MVC application, you would need to add the following to the &hellip;<\/p>\n","protected":false},"author":267,"featured_media":240,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[856,30],"class_list":["post-18414","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-jstl","tag-spring"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Exploring Spring Controller with JSTL view<\/title>\n<meta name=\"description\" content=\"Let\u2019s improve our previous Spring JDBC application with some more exploration on Spring MVC\u2019s Controller development. I will show another exercise of\" \/>\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\/10\/exploring-spring-controller-with-jstl-view.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Exploring Spring Controller with JSTL view\" \/>\n<meta property=\"og:description\" content=\"Let\u2019s improve our previous Spring JDBC application with some more exploration on Spring MVC\u2019s Controller development. I will show another exercise of\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2013\/10\/exploring-spring-controller-with-jstl-view.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-10-26T12:00:19+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=\"Zemian Deng\" \/>\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=\"Zemian Deng\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"10 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/10\\\/exploring-spring-controller-with-jstl-view.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/10\\\/exploring-spring-controller-with-jstl-view.html\"},\"author\":{\"name\":\"Zemian Deng\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/decbcaa8856a153c212bedba0079233a\"},\"headline\":\"Exploring Spring Controller with JSTL view\",\"datePublished\":\"2013-10-26T12:00:19+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/10\\\/exploring-spring-controller-with-jstl-view.html\"},\"wordCount\":890,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/10\\\/exploring-spring-controller-with-jstl-view.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"keywords\":[\"JSTL\",\"Spring\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/10\\\/exploring-spring-controller-with-jstl-view.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/10\\\/exploring-spring-controller-with-jstl-view.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/10\\\/exploring-spring-controller-with-jstl-view.html\",\"name\":\"Exploring Spring Controller with JSTL view\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/10\\\/exploring-spring-controller-with-jstl-view.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/10\\\/exploring-spring-controller-with-jstl-view.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"datePublished\":\"2013-10-26T12:00:19+00:00\",\"description\":\"Let\u2019s improve our previous Spring JDBC application with some more exploration on Spring MVC\u2019s Controller development. I will show another exercise of\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/10\\\/exploring-spring-controller-with-jstl-view.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/10\\\/exploring-spring-controller-with-jstl-view.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/10\\\/exploring-spring-controller-with-jstl-view.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\\\/10\\\/exploring-spring-controller-with-jstl-view.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\":\"Exploring Spring Controller with JSTL view\"}]},{\"@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\\\/decbcaa8856a153c212bedba0079233a\",\"name\":\"Zemian Deng\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a52e12ea83eca65c46f00caeddaf307d5d531c3d28ad5219d7bd7e27c45e373f?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a52e12ea83eca65c46f00caeddaf307d5d531c3d28ad5219d7bd7e27c45e373f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a52e12ea83eca65c46f00caeddaf307d5d531c3d28ad5219d7bd7e27c45e373f?s=96&d=mm&r=g\",\"caption\":\"Zemian Deng\"},\"sameAs\":[\"http:\\\/\\\/saltnlight5.blogspot.com\\\/\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/Zemian-Deng\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Exploring Spring Controller with JSTL view","description":"Let\u2019s improve our previous Spring JDBC application with some more exploration on Spring MVC\u2019s Controller development. I will show another exercise of","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\/10\/exploring-spring-controller-with-jstl-view.html","og_locale":"en_US","og_type":"article","og_title":"Exploring Spring Controller with JSTL view","og_description":"Let\u2019s improve our previous Spring JDBC application with some more exploration on Spring MVC\u2019s Controller development. I will show another exercise of","og_url":"https:\/\/www.javacodegeeks.com\/2013\/10\/exploring-spring-controller-with-jstl-view.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2013-10-26T12:00:19+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":"Zemian Deng","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Zemian Deng","Est. reading time":"10 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2013\/10\/exploring-spring-controller-with-jstl-view.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/10\/exploring-spring-controller-with-jstl-view.html"},"author":{"name":"Zemian Deng","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/decbcaa8856a153c212bedba0079233a"},"headline":"Exploring Spring Controller with JSTL view","datePublished":"2013-10-26T12:00:19+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/10\/exploring-spring-controller-with-jstl-view.html"},"wordCount":890,"commentCount":0,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/10\/exploring-spring-controller-with-jstl-view.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","keywords":["JSTL","Spring"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2013\/10\/exploring-spring-controller-with-jstl-view.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2013\/10\/exploring-spring-controller-with-jstl-view.html","url":"https:\/\/www.javacodegeeks.com\/2013\/10\/exploring-spring-controller-with-jstl-view.html","name":"Exploring Spring Controller with JSTL view","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/10\/exploring-spring-controller-with-jstl-view.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/10\/exploring-spring-controller-with-jstl-view.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","datePublished":"2013-10-26T12:00:19+00:00","description":"Let\u2019s improve our previous Spring JDBC application with some more exploration on Spring MVC\u2019s Controller development. I will show another exercise of","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/10\/exploring-spring-controller-with-jstl-view.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2013\/10\/exploring-spring-controller-with-jstl-view.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2013\/10\/exploring-spring-controller-with-jstl-view.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\/10\/exploring-spring-controller-with-jstl-view.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":"Exploring Spring Controller with JSTL view"}]},{"@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\/decbcaa8856a153c212bedba0079233a","name":"Zemian Deng","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/a52e12ea83eca65c46f00caeddaf307d5d531c3d28ad5219d7bd7e27c45e373f?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/a52e12ea83eca65c46f00caeddaf307d5d531c3d28ad5219d7bd7e27c45e373f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/a52e12ea83eca65c46f00caeddaf307d5d531c3d28ad5219d7bd7e27c45e373f?s=96&d=mm&r=g","caption":"Zemian Deng"},"sameAs":["http:\/\/saltnlight5.blogspot.com\/"],"url":"https:\/\/www.javacodegeeks.com\/author\/Zemian-Deng"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/18414","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\/267"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=18414"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/18414\/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=18414"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=18414"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=18414"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}