Estou utilizando struts2 + tiles2 por annotation, fica a seguinte configuração em minha action:
@TilesDefinitions(value = {
@TilesDefinition (name = "baseLayout", template="/css/baseLayout.jsp", putAttributes = {
@TilesPutAttribute(name = "title", value = "Portal do Requerente"),
@TilesPutAttribute(name = "body", value = "conteudo da pagina"),
}
),
@TilesDefinition (name = "loginRequerente", extend="baseLayout", putAttributes = {
@TilesPutAttribute(name = "body", value = "/login/login_requerente/login.jsp"),
}
)
})
O método estou achando assim:
@Action(value = "inicio", results = @Result(name = "loginRequerente", type="tiles"))
public String loginRequerente(){
return "loginRequerente";
}
Ou seja, quando eu chamar o ação inicio na tela irá me retornar “loginRequerente” na action do tipo tiles.
No tiles eu defini que o “loginRequerente” iria substituir a tag “body” com a página lá.
Sendo pelo annotation parece que ele não está achando o “loginRequerente”, ele só exibe o que está na baseLayout.jsp.
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:web="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee" version="2.5">
<listener>
<listener-class>org.apache.struts2.tiles.StrutsTilesListener</listener-class>
</listener>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
<init-param>
<param-name>struts.devMode</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>UTF8Filter</filter-name>
<filter-class>utils.UTF8Filter</filter-class>
</filter>
<filter-mapping>
<filter-name>UTF8Filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>/blank.jsp</welcome-file>
</welcome-file-list>
<session-config>
<session-timeout>20</session-timeout>
</session-config>
</web-app>
No struts.xml eu adicionei o tiles-default.