Problème de forward de l'action
Bonjour je debute sous struts 1.3.8
j'ai fait un petite application pour login d'un utilisateur mais mon action ne fait aucun forward vers la page d'acueil, tout juste j'ai une page blanche, il y a aucun affichage
est ce quelqu'un peut m'aider ?
voici mon web.xml :
Code:
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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
| <?xml version="1.0" encoding="iso-8859-1" ?>
<!DOCTYPE web-app (View Source for full doctype...)>
- <web-app>
<display-name>Welcome to home page</display-name>
- <!-- Standard Action Servlet Configuration (with debugging)
-->
- <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</param-value>
</init-param>
- <init-param>
<param-name>debug</param-name>
<param-value>2</param-value>
</init-param>
- <init-param>
<param-name>detail</param-name>
<param-value>2</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
- <!-- Standard Action Servlet Mapping
-->
- <servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
- <!-- The Usual Welcome File List
-->
- <!-- Struts Tag Library Descriptors
-->
- <taglib>
<taglib-uri>/WEB-INF/struts-bean</taglib-uri>
<taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
</taglib>
- <taglib>
<taglib-uri>/WEB-INF/struts-html</taglib-uri>
<taglib-location>/WEB-INF/struts-html.tld</taglib-location>
</taglib>
- <taglib>
<taglib-uri>/WEB-INF/struts-logic</taglib-uri>
<taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
</taglib>
- <taglib>
<taglib-uri>/WEB-INF/struts-nested</taglib-uri>
<taglib-location>/WEB-INF/struts-nested.tld</taglib-location>
</taglib>
- <welcome-file-list>
<welcome-file>login.jsp</welcome-file>
</welcome-file-list>
</web-app> |
Voici mon struts-config.xml
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| <?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE struts-config (View Source for full doctype...)>
- <struts-config>
- <form-beans>
<form-bean name="loginForm" type="app.LoginForm" />
</form-beans>
- <!-- <global-forwards
type="org.apache.struts.action.ActionForward">
</global-forwards>
-->
- <action-mappings>
- <action path="/login" type="app.LoginAction" unknown="true" name="loginForm" scope="request" input="/login.jsp" validate="true">
<forward name="success" path="/connected.jsp" redirect="true" />
</action>
</action-mappings>
<message-resources parameter="app.MessageResources" />
- <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property property="pathnames" value="/org/apache/struts/validator/validator-rules.xml, /WEB-INF/validation.xml" />
</plug-in>
</struts-config> |
Mon LoginForm.java
Code:
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 37 38 39 40 41 42 43 44
| package app;
import org.apache.struts.action.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.apache.struts.validator.*;
public class LoginForm extends ActionForm {
private String username;
private String password;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
ActionErrors errors = new ActionErrors();
if (this.getUsername().length()<2 && this.getPassword().length() < 3) {
errors.add("username", new ActionMessage("error.index.usename"));
errors.add("password", new ActionMessage("error.index.password"));
}
return errors;
}
public void reset(ActionMapping mapping, HttpServletRequest request) {
this.password = null;
this.username = null;
}
} |
et mon action
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| package app;
import javax.servlet.http.*;
import org.apache.struts.action.*;
public class LoginAction extends Action {
public static String SUCCESS = "success";
public ActionForward excute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception {
LoginForm subform = (LoginForm)form;
request.setAttribute("username", subform.getUsername());
request.setAttribute("password", subform.getPassword());
return (mapping.findForward(SUCCESS));
}
} |
ma page d'accueil
Code:
1 2 3 4 5 6 7
| <html>
...................
Bienvenue <bean: write name="loginForm" property="username"/>
.......
</html> |
// cette page ne s'affiche pas