spring-3tiles-3

Spring 3.2.5 tiles 3 not rendering the view


I have gone through other post of rendering the view using spring3.2.5 & tiles3

in my context-servlet.xml

<bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
  <property name="viewClass">
     <value>
        org.springframework.web.servlet.view.tiles3.TilesView
     </value>
  </property>

In my tiles-servlet.xml

<bean id="tilesConfigurer"
    class="org.springframework.web.servlet.view.tiles3.TilesConfigurer">
<property name="definitions">
     <list>
          <value>/WEB-INF/tiles/common/tiles.xml</value>
          <value>/WEB-INF/tiles/common/base_tiles.xml</value>
              <value>/WEB-INF/tiles/common/person_tiles.xml</value>
      </list>
</property>
</bean> 

In person_tiles.xml

<?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE tiles-definitions PUBLIC
   "-//Apache Software Foundation//DTD Tiles Configuration 3.0//EN"
   "http://tiles.apache.org/dtds/tiles-config_3_0.dtd">
<tiles-definitions>

     <definition name="new_person" extends="base.definition">
        <put-attribute name="body" value="/WEB-INF/xx/xxx/web_person.jsp" />
     </definition>
</tiles-defnitions>

It throws below error javax.servlet.ServletException: Could not resolve view with name 'new_person' in servlet with name 'project'

please help me to solve the issue.


Solution

  • Related issue discussing this "behavior" is SPR-11491 and is specific to Tiles v3.

    It comes from SpringWildcardServletTilesApplicationContext.getResources(String) -> URLApplicationResource(String, URL) constructor -> super PostfixedApplicationResource(String localePath) constructor. When there is an underscore in definition filenames, the string after the last underscore is identified as the locale.

    The Tiles section of Spring 4.0.3 reference documentation has been updated in order to make this behavior more explicit, and there are ongoing discussion with Tiles development team to get this fixed by checking the locale against Locale.getISOLanguageCodes() in order to get a less surprising default behavior.