Bonjour à tous.
Je cherche ç changer la langue de mon application, mais je n'y arrive pas. Je me suis appuyé sur cette page http://javaweb.developpez.com/faq/struts/?page=i18n mais mon appli n'appel pas la méthode execute(). J'ai beau chercher sur le net je ne trouve pas se qu'il me manque. Quelqu'un pourrait-il m'aider?
Voici mes sources :
Mon jsp:
Mon action :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 <html:form action="indexForm" focus="language"> <table border="0" align="center"> <!-- Bouton de passage en langue française --> <html:link page='/index.jsp?lang=fr&cty=FR' styleClass="action"> <html:img page="/images/FR.png" /> </html:link> <!-- Bouton de passage en langue anglaise --> <html:link page='/index.jsp?lang=en&cty=EN' styleClass="action"> <html:img page="/images/EN.png" /> </html:link> </table> <br> </html:form>
Mon struts-config :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 public class IndexAction extends Action { public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { // récupération des paramètres passés et de l'url du referer String country = request.getParameter("cty"); String language = request.getParameter("lang"); String referer = request.getHeader("referer"); ActionForward forward = null; // définition de la locale this.setLocale(request, new Locale(language, country)); // redirection vers une page définie par défaut if (referer == null) { forward = (mapping.findForward("home")); } // redirection vers l'url du referrer. else { forward = new RedirectingActionForward(); forward.setPath(referer); } return forward; } }
Merci d'avance pour votre aide.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 <form-beans type="org.apache.struts.action.ActionFormBean"> <form-bean name="identificationForm" type="Struts1.IdentificationForm" /> <form-bean name="indexForm" type="Struts1.IndexForm" /> </form-beans> <action-mappings type="org.apache.struts.action.ActionMapping"> <action path="/identificationForm" type="Struts1.IdentificationAction" name="identificationForm" scope="request" validate="true" parameter="operation" input="/index.jsp"> <forward name="succes" path="/identification.jsp" redirect="false" /> <forward name="echec" path="/index.jsp" redirect="false" /> </action> <action path="/indexForm" type="Struts1.IndexAction" name="indexForm" scope="request" validate="false" input="/index.jsp"> <forward name="home" path="/index.jsp" redirect="false" /> </action> </action-mappings> <message-resources parameter="ApplicationResources" />
Partager