2012-12-07 16 views
5

È possibile utilizzare Tiles2 con Struts 1?Come utilizzare Tiles2 con Struts 1

Ho seguito le istruzioni disponibili presso la guida alla migrazione http://tiles.apache.org/migration/index.html

Ma quando provo ad accedere le mie azioni, ottengo questo errore:

org.apache.tiles.template.NoSuchAttributeException: Attribute 'body' not found. 

ho in struts-config.xml:

<controller processorClass="org.apache.struts.tiles.TilesRequestProcessor" 
    maxFileSize="10M" tempDir="/tmp" /> 

<plug-in className="org.apache.struts.tiles.TilesPlugin"> 
    <set-property property="definitions-config" value="/WEB-INF/tiles-defs.xml" /> 
</plug-in> 

e piastrelle-defs.xml

<definition name="mainTemplate" template="/common/templates/mainTemplate.jsp" /> 
    <definition name="index" extends="mainTemplate"> 
     <put-attribute name="body" type="string" value="/views/index/index.jsp" /> 
    </definition> 

risposta

1

apportare le seguenti modifiche nel vostro struts-config.xml

<controller processorClass=”org.apache.struts.tiles2.TilesRequestProcessor”/> 
<plug-in className=”org.apache.struts.tiles2.TilesPlugin” > 

trovare le fonti per il plugin Tiles2 here.

-2

Sì, è possibile utilizzarlo con puntoni 1. Check their site.

Put attributi in voi piastrelle di file per mainTemplate Come:

<definition name="mainTemplate" path="/common/templates/mainTemplate.jsp"> 
    <put name="title" value="Tiles Example" /> 
    <put name="header" value="/header.jsp" /> 
    <put name="menu" value="/menu.jsp" /> 
    <put name="body" value="/body.jsp" /> 
    <put name="footer" value="/footer.jsp" /> 
</definition> 

Se questo non ha funzionato quindi provare modificare la struts-config.xml come:

<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE struts-config PUBLIC 
"-//Apache Software Foundation//DTD Struts Configuration 1.3//EN" 
"http://jakarta.apache.org/struts/dtds/struts-config_1_3.dtd"> 

<struts-config> 

    <action-mappings> 

     <action 
      path="/User" 
      type="org.apache.struts.actions.ForwardAction" 
      parameter="/pages/user/user-form.jsp"/> 

    </action-mappings> 

    <plug-in className="org.apache.struts.tiles.TilesPlugin" > 
     <set-property property="definitions-config" 
     value="/WEB-INF/tiles-defs.xml"/> 
    </plug-in> 

</struts-config> 
+0

questa è la soluzione per le piastrelle 1. Ho bisogno di usa le piastrelle 2 –