title: Spring Web MVC Tiles Attribute 'header' not found
body: <p>I am trying to use tiles library in my spring MVC project.</p>
  
  <p>wel-servlet.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:context="http://www.springframework.org/schema/context"
      xmlns:p="http://www.springframework.org/schema/p"
      xmlns:tx="http://www.springframework.org/schema/tx"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="
          http://www.springframework.org/schema/beans     
          http://www.springframework.org/schema/beans/spring-beans.xsd
          http://www.springframework.org/schema/context 
          http://www.springframework.org/schema/context/spring-context.xsd
          http://www.springframework.org/schema/tx
          http://www.springframework.org/schema/tx/spring-tx.xsd
          http://www.springframework.org/schema/mvc
          http://www.springframework.org/schema/mvc/spring-mvc.xsd"
      xmlns:mvc="http://www.springframework.org/schema/mvc"&gt;
  
      &lt;context:annotation-config /&gt;
      &lt;context:component-scan base-package="com.smart" /&gt;
      &lt;mvc:annotation-driven /&gt;
      &lt;tx:annotation-driven transaction-manager="myTransactionManager" /&gt;
  
      &lt;bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;
          &lt;property name="prefix" value="/view/" /&gt;
          &lt;property name="suffix" value=".jsp" /&gt;
      &lt;/bean&gt;
  
      &lt;mvc:resources mapping="/resources/**" location="/resources/theme1/" /&gt;
  
      &lt;bean id="tilesViewResolver"
          class="org.springframework.web.servlet.view.UrlBasedViewResolver"&gt;
          &lt;property name="viewClass"&gt;
              &lt;value&gt;
                  org.springframework.web.servlet.view.tiles3.TilesView
              &lt;/value&gt;
          &lt;/property&gt; 
      &lt;/bean&gt;
      &lt;bean id="tilesConfigurer"
          class="org.springframework.web.servlet.view.tiles3.TilesConfigurer"&gt;
          &lt;property name="definitions"&gt;
              &lt;list&gt;
                  &lt;value&gt;/WEB-INF/tiles.xml&lt;/value&gt;
              &lt;/list&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>tiles.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE tiles-definitions PUBLIC "-//Apache Software Foundation//DTD Tiles Configuration 3.0//EN"
  "http://tiles.apache.org/dtds/tiles-config_3_0.dtd"&gt;
  
  &lt;tiles-definitions&gt;
      &lt;definition name="login" template="/view/home.jsp"&gt;
          &lt;put-attribute name="title" value="" /&gt;
          &lt;put-attribute name="header" value="/view/header.jsp" /&gt;
          &lt;put-attribute name="body" value="" /&gt;
          &lt;put-attribute name="footer" value="" /&gt;
      &lt;/definition&gt;
  &lt;/tiles-definitions&gt;
  </code></pre>
  
  <p>home.jsp</p>
  
  <pre><code>&lt;%@page contentType="text/html" pageEncoding="UTF-8"%&gt;
  &lt;%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %&gt;
  &lt;%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %&gt;
  &lt;%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %&gt;
  &lt;%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %&gt;
  &lt;%@ taglib prefix="tiles" uri="http://tiles.apache.org/tags-tiles" %&gt;
  
  &lt;html&gt;
  &lt;head&gt;
      &lt;Title&gt;Home&lt;/Title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;tiles:insertAttribute name="header" /&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>ProfilePage.java</p>
  
  <pre><code>@Controller
  public class ProfilePage {
  
          @RequestMapping(value = "/login", method=RequestMethod.GET)
      public ModelAndView showPost(@ModelAttribute("commentForm") Post post, ModelMap model, HttpSession session)
      {
               return new ModelAndView("home", model);
          }
  
          @RequestMapping(value = "/login", method=RequestMethod.POST)
      public ModelAndView loginWorld(ModelMap model, @ModelAttribute("commentForm") Post post, @ModelAttribute("loginForm") Employee employee, HttpSession session, BindingResult errorResult){
  
               // Logic
  
                  model.addAttribute("result", result);
          return new ModelAndView(returnPage, model);
      }
  }
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code>org.apache.jasper.JasperException: org.apache.tiles.template.NoSuchAttributeException: Attribute 'header' not found.
      org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:549)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:470)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
      org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:168)
      org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:303)
      org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1244)
      org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1027)
      org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:971)
      org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
      org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:967)
      org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:869)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
      org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:843)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
  
  root cause
  
  org.apache.tiles.template.NoSuchAttributeException: Attribute 'header' not found.
      org.apache.tiles.template.DefaultAttributeResolver.computeAttribute(DefaultAttributeResolver.java:50)
      org.apache.tiles.template.InsertAttributeModel.resolveAttribute(InsertAttributeModel.java:165)
      org.apache.tiles.template.InsertAttributeModel.execute(InsertAttributeModel.java:121)
      org.apache.tiles.jsp.taglib.InsertAttributeTag.doTag(InsertAttributeTag.java:299)
      org.apache.jsp.view.home_jsp._jspx_meth_tiles_005finsertAttribute_005f0(home_jsp.java:379)
      org.apache.jsp.view.home_jsp._jspx_meth_c_005fif_005f0(home_jsp.java:318)
      org.apache.jsp.view.home_jsp._jspService(home_jsp.java:147)
      org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
      org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:168)
      org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:303)
      org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1244)
      org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1027)
      org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:971)
      org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
      org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:967)
      org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:869)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
      org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:843)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
  </code></pre>
  
  <p>I am not getting why this error is coming!! </p>