Seguimos con el tutorial de struts
Página jsp con varios ejemplos de utilización de comodines (wildcard)
Creamos un fichero de configuración struts específico para el ejemplo y lo integramos en el fichero descriptor de despliegue en struts-configWildcard.xml
1 2 3 4 5 6 7 8 9 10 | <!-- Standard Action Servlet Configuration --> <servlet> <servlet-name>action</servlet-name> <servlet-class>org.apache.struts.action.ActionServlet</servlet-class> <init-param> <param-name>config</param-name> <param-value>/WEB-INF/struts-config.xml , /WEB-INF/struts-config2.xml , /WEB-INF/struts-configWildcard.xml </param-value> </init-param> <load-on-startup>2</load-on-startup> </servlet> |
Configuración del archivo struts-configWildcard.xml
1 2 3 4 5 6 7 8 9 10 11 | struts-config> <!-- se puede aplicar a los --> <action-mappings> <action path="/enlaces" forward="/pages/enlaces.jsp"/> <action path="/Primero*" forward="/pages/Wildcard/Paginap1.jsp"/> <action path="/*segundo" forward="/pages/Wildcard/{1}.jsp"/> </action-mappings> </struts-config> |
código de enlaces.jsp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@taglib uri="http://struts.apache.org/tags-html" prefix="html" %> <%@taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title><bean:message key="wildcard.enlace.titulo"/> </title> <html:base/> <link rel="stylesheet" href="../css/estilo.css" type="text/css"/> </head> <body> <div id="contenedor"> <h2> Enlaces </h2> <div id="contenido"> <div id="campo"> <html:link action="PrimeroPaginap1"> primero página p1</html:link> </div> <div id="campo"> <html:link action="Paginap1segundo"> página p1 segundo </html:link> </div> <div id="campo"> <html:link action="Paginap2segundo"> primera página p2 </html:link> </div> </div> <div id="pie"> <p> www.railsymas.com </p> </div> </div> </body> </html> |
Las páginas jsp son simples, no tienen ningun código especial
página 1 jsp
página 2 jsp



