Configurar los taglibs de Struts para la aplicación web

2617 vistas

Struts se entrega con bibliotecas de etiquetas estándars.

Para poder tilizarlas en las páginas JSP, tendremos que declararlas en sus descriptores en el fichero de configuración web.xml.

Sea cual sea la taglib, su declaración será asÃ:



xml
  1. <web-app>
  2.   ...
  3.   <taglib>
  4.     <taglib-uri>AliasTaglib;</taglib-uri>
  5.  
  6.     <taglib-location>PathRelativoAlContexto/NombreDelDescriptor</taglib-location>
  7.   </taglib>
  8. </web-app>



Por ejemplo para la taglib html de Struts:



xml
  1. <web-app>
  2.   ...
  3.   <taglib>
  4.     <taglib-uri>StrutsHtml</taglib-uri>
  5.     <taglib-location>/WEB-INF/struts-html.tld</taglib-location>
  6.   </taglib>
  7. </web-app>



En el JSP, tendremos que hacer referencia al taglib:



html4strict
  1. <%@ taglib uri="StrutsHtml" prefix="html" %> <html:html> ... </html:html>



Nota: es aconsejable declarar el path relativo como alias.