{"id":631,"date":"2011-10-13T00:30:00","date_gmt":"2011-10-13T00:30:00","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/2012\/10\/spring-mvc-interceptors-example.html"},"modified":"2012-10-21T20:29:15","modified_gmt":"2012-10-21T20:29:15","slug":"spring-mvc-interceptors-example","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2011\/10\/spring-mvc-interceptors-example.html","title":{"rendered":"Spring MVC Interceptors Example"},"content":{"rendered":"<div dir=\"ltr\" style=\"text-align: left\">I thought that it was time to take a look at Spring\u2019s MVC interceptor mechanism, which has been around for a good number of years and is a really useful tool.<\/p>\n<p>A Spring Interceptor does what it says on the tin: intercepts an incoming HTTP request before it reaches your Spring MVC controller class, or conversely, intercepts the outgoing HTTP response after it leaves your controller, but before it\u2019s fed back to the browser.<\/p>\n<p>You may ask what use is this to you? The answer is that it allows you to perform tasks that are common to every request or set of requests without the need to cut \u2018n\u2019 paste boiler plate code into every controller class. For example, you could perform user authentication of a request before it reaches your controller and, if successful, retrieve some additional user details from a database adding them to the HttpServletRequest object before your controller is called. Your controller can then simply retrieve and use these values or leave them for display by the JSP. On the other hand, if the authentication fails, you could re-direct your user to a different page.<\/p>\n<p>The demonstration code shows you how to modify the incoming HttpServletRequest object before it reaches your controller. This does nothing more than add a simple string to the request, but, as I said above, you could always make a database call to grab hold of some data that\u2019s required by every request&#8230; you could even add some kind of <a href=\"http:\/\/www.captaindebug.com\/2011\/04\/code-optimization.html\">optimization<\/a> and do some caching at this point.<\/p>\n<pre class=\"brush:java\">public class RequestInitializeInterceptor extends HandlerInterceptorAdapter {\r\n\r\n  \/\/ Obtain a suitable logger.\r\n  private static Log logger = LogFactory\r\n      .getLog(RequestInitializeInterceptor.class);\r\n\r\n  \/**\r\n   * In this case intercept the request BEFORE it reaches the controller\r\n   *\/\r\n  @Override\r\n  public boolean preHandle(HttpServletRequest request,\r\n      HttpServletResponse response, Object handler) throws Exception {\r\n    try {\r\n\r\n      logger.info(\"Intercepting: \" + request.getRequestURI());\r\n\r\n      \/\/ Do some changes to the incoming request object\r\n      updateRequest(request);\r\n\r\n      return true;\r\n    } catch (SystemException e) {\r\n      logger.info(\"request update failed\");\r\n      return false;\r\n    }\r\n  }\r\n\r\n  \/**\r\n   * The data added to the request would most likely come from a database\r\n   *\/\r\n  private void updateRequest(HttpServletRequest request) {\r\n\r\n    logger.info(\"Updating request object\");\r\n    request.setAttribute(\"commonData\",\r\n        \"This string is required in every request\");\r\n  }\r\n\r\n  \/** This could be any exception *\/\r\n  private class SystemException extends RuntimeException {\r\n\r\n    private static final long serialVersionUID = 1L;\r\n    \/\/ Blank\r\n  }\r\n}\r\n<\/pre>\n<p>In the code above, I\u2019ve chosen the simplest implementation method by extending the HandlerInterceptorAdaptor class, overriding preHandle(..) method. My preHandle(&#8230;) method does the error handling, deciding what to do if an error occurs and returning false if one does. In returning false the interceptor chain is broken and your controller class is not called. The actual business of messing with the request object is delegated to updateRequest(request).<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p>The HandlerInterceptorAdaptor class has three methods, each of which are stubbed and, if desired, can be ignored. The methods are: prehandle(&#8230;), postHandle(&#8230;) and afterCompletion(&#8230;) and more information on these can be found in the <a href=\"http:\/\/static.springsource.org\/spring\/docs\/3.0.x\/javadoc-api\/\">Spring API documentation<\/a>. Be aware that this can be somewhat confusing as the Handler Interceptor classes documentation still refer to MVC controller classes by their Spring 2 name of handlers. This point is easily demonstrated if you look at prehandle(&#8230;)\u2019s third parameter of type Object and called handler. If you examine this in your debugger, you\u2019ll see that it is an instance of your controller class. If you\u2019re new to this technique, just remember that controller == handler.<\/p>\n<p>The next step in implementing an interceptor is, as always, to add something to the Spring XML config file:<\/p>\n<pre class=\"brush:xml\">&lt;!-- Configures Handler Interceptors --&gt; \r\n&lt;mvc:interceptors&gt;  \r\n &lt;!-- This bit of XML will intercept all URLs - which is what you want in a web app --&gt;\r\n &lt;bean class=\"marin.interceptor.RequestInitializeInterceptor\" \/&gt;\r\n \r\n &lt;!-- This bit of XML will apply certain URLs to certain interceptors --&gt;\r\n &lt;!-- \r\n &lt;mvc:interceptor&gt;\r\n  &lt;mvc:mapping path=\"\/gb\/shop\/**\"\/&gt;\r\n  &lt;bean class=\"marin.interceptor.RequestInitializeInterceptor\" \/&gt;\r\n &lt;\/mvc:interceptor&gt;\r\n  --&gt;\r\n&lt;\/mvc:interceptors&gt;\r\n<\/pre>\n<p>The XML above demonstrates an either\/or choice of adding an interceptor to all request URLs, or if you look at the commented out section, adding an interceptor to specific request URLs, allowing you to choose which URLs are connected to your interceptor class.<\/p>\n<p>The eagle eyed readers may have noticed that the interceptor classes use inheritance and XML config as its method of implementation. In these days of convention over configuration, this pattern is beginning to look a little jaded and could probably do with a good overhaul. One suggestion would be to enhance the whole lot to use annotations, applying the same techniques that have already been added to the controller mechanism. This would add extra flexibility without the complication of using all the interfaces and abstract base classes. As a suggestion, a future interceptor class implementation could look something like this:<\/p>\n<pre class=\"brush:java\">@Intercept(value = \"\/gb\/en\/*\", method = RequestMethod.POST)\r\n  public boolean myAuthenticationHandler(HttpServletRequest request,\r\n      Model model) {\r\n    \/\/ Put some code here\r\n  }\r\n<\/pre>\n<p>That concludes this look at Spring interceptors, it should be remembered that I\u2019ve only demonstrated the most basic implementation.<\/p>\n<p><strong><i>Reference: <\/i><\/strong><a href=\"http:\/\/www.captaindebug.com\/2011\/09\/using-spring-interceptors-in-your-mvc.html\">Using Spring Interceptors in your MVC Webapp<\/a> from our <a href=\"http:\/\/www.javacodegeeks.com\/p\/jcg.html\">JCG partner<\/a> Roger Hughes at the <a href=\"http:\/\/www.captaindebug.com\/\">Captain Debug&#8217;s blog<\/a>.<\/p>\n<div style=\"margin: 0px\"><strong><i>Related Articles :<\/i><\/strong><\/div>\n<ul>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2011\/07\/jqgrid-rest-ajax-spring-mvc-integration.html\">jqGrid, REST, AJAX and Spring MVC Integration<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2011\/06\/springmvc-3-tiles-222-integration.html\">SpringMVC 3 Tiles 2.2.2 Integration Tutorial<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2011\/04\/spring-mvc3-hibernate-crud-sample.html\">Spring MVC3 Hibernate CRUD Sample Application<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2011\/02\/spring-mvc-development-tutorial.html\">Spring MVC Development &#8211; Quick Tutorial<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2011\/06\/spring-quartz-javamail-tutorial.html\">Spring, Quartz and JavaMail Integration Tutorial<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2011\/10\/spring-insight-web-application.html\">Spring Insight &#8211; Web Application Profiling<\/a>&nbsp;<\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/p\/java-tutorials.html\">Java Tutorials and Android Tutorials list<\/a> <\/li>\n<\/ul>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>I thought that it was time to take a look at Spring\u2019s MVC interceptor mechanism, which has been around for a good number of years and is a really useful tool. A Spring Interceptor does what it says on the tin: intercepts an incoming HTTP request before it reaches your Spring MVC controller class, or &hellip;<\/p>\n","protected":false},"author":65,"featured_media":240,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[30,150],"class_list":["post-631","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 Interceptors Example - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"I thought that it was time to take a look at Spring\u2019s MVC interceptor mechanism, which has been around for a good number of years and is a really useful\" \/>\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\/2011\/10\/spring-mvc-interceptors-example.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Spring MVC Interceptors Example - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"I thought that it was time to take a look at Spring\u2019s MVC interceptor mechanism, which has been around for a good number of years and is a really useful\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2011\/10\/spring-mvc-interceptors-example.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=\"2011-10-13T00:30:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2012-10-21T20:29:15+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=\"Roger Hughes\" \/>\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=\"Roger Hughes\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/10\\\/spring-mvc-interceptors-example.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/10\\\/spring-mvc-interceptors-example.html\"},\"author\":{\"name\":\"Roger Hughes\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/c9feacaf8e783104a69621cd65bf1f07\"},\"headline\":\"Spring MVC Interceptors Example\",\"datePublished\":\"2011-10-13T00:30:00+00:00\",\"dateModified\":\"2012-10-21T20:29:15+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/10\\\/spring-mvc-interceptors-example.html\"},\"wordCount\":692,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/10\\\/spring-mvc-interceptors-example.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\\\/2011\\\/10\\\/spring-mvc-interceptors-example.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/10\\\/spring-mvc-interceptors-example.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/10\\\/spring-mvc-interceptors-example.html\",\"name\":\"Spring MVC Interceptors Example - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/10\\\/spring-mvc-interceptors-example.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/10\\\/spring-mvc-interceptors-example.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"datePublished\":\"2011-10-13T00:30:00+00:00\",\"dateModified\":\"2012-10-21T20:29:15+00:00\",\"description\":\"I thought that it was time to take a look at Spring\u2019s MVC interceptor mechanism, which has been around for a good number of years and is a really useful\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/10\\\/spring-mvc-interceptors-example.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/10\\\/spring-mvc-interceptors-example.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/10\\\/spring-mvc-interceptors-example.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\\\/2011\\\/10\\\/spring-mvc-interceptors-example.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 Interceptors Example\"}]},{\"@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\\\/c9feacaf8e783104a69621cd65bf1f07\",\"name\":\"Roger Hughes\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/db9d1e5362dbc3f8007b383b852473b59fb8c5282a6066a13ab1cef761a9d5d6?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/db9d1e5362dbc3f8007b383b852473b59fb8c5282a6066a13ab1cef761a9d5d6?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/db9d1e5362dbc3f8007b383b852473b59fb8c5282a6066a13ab1cef761a9d5d6?s=96&d=mm&r=g\",\"caption\":\"Roger Hughes\"},\"sameAs\":[\"http:\\\/\\\/www.captaindebug.com\\\/\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/Roger-Hughes\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Spring MVC Interceptors Example - Java Code Geeks","description":"I thought that it was time to take a look at Spring\u2019s MVC interceptor mechanism, which has been around for a good number of years and is a really useful","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\/2011\/10\/spring-mvc-interceptors-example.html","og_locale":"en_US","og_type":"article","og_title":"Spring MVC Interceptors Example - Java Code Geeks","og_description":"I thought that it was time to take a look at Spring\u2019s MVC interceptor mechanism, which has been around for a good number of years and is a really useful","og_url":"https:\/\/www.javacodegeeks.com\/2011\/10\/spring-mvc-interceptors-example.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2011-10-13T00:30:00+00:00","article_modified_time":"2012-10-21T20:29:15+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":"Roger Hughes","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Roger Hughes","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2011\/10\/spring-mvc-interceptors-example.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/10\/spring-mvc-interceptors-example.html"},"author":{"name":"Roger Hughes","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/c9feacaf8e783104a69621cd65bf1f07"},"headline":"Spring MVC Interceptors Example","datePublished":"2011-10-13T00:30:00+00:00","dateModified":"2012-10-21T20:29:15+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/10\/spring-mvc-interceptors-example.html"},"wordCount":692,"commentCount":1,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/10\/spring-mvc-interceptors-example.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\/2011\/10\/spring-mvc-interceptors-example.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2011\/10\/spring-mvc-interceptors-example.html","url":"https:\/\/www.javacodegeeks.com\/2011\/10\/spring-mvc-interceptors-example.html","name":"Spring MVC Interceptors Example - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/10\/spring-mvc-interceptors-example.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/10\/spring-mvc-interceptors-example.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","datePublished":"2011-10-13T00:30:00+00:00","dateModified":"2012-10-21T20:29:15+00:00","description":"I thought that it was time to take a look at Spring\u2019s MVC interceptor mechanism, which has been around for a good number of years and is a really useful","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/10\/spring-mvc-interceptors-example.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2011\/10\/spring-mvc-interceptors-example.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2011\/10\/spring-mvc-interceptors-example.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\/2011\/10\/spring-mvc-interceptors-example.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 Interceptors Example"}]},{"@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\/c9feacaf8e783104a69621cd65bf1f07","name":"Roger Hughes","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/db9d1e5362dbc3f8007b383b852473b59fb8c5282a6066a13ab1cef761a9d5d6?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/db9d1e5362dbc3f8007b383b852473b59fb8c5282a6066a13ab1cef761a9d5d6?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/db9d1e5362dbc3f8007b383b852473b59fb8c5282a6066a13ab1cef761a9d5d6?s=96&d=mm&r=g","caption":"Roger Hughes"},"sameAs":["http:\/\/www.captaindebug.com\/"],"url":"https:\/\/www.javacodegeeks.com\/author\/Roger-Hughes"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/631","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\/65"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=631"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/631\/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=631"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=631"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=631"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}