salut
quand je lance localhost:8080/struts1/login.jsp j ai
et un message d'erreur dans localhost:8080/struts1/index2.jsp
login.jsp
sucess.jsp
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 <%@page contentType="text/html" pageEncoding="UTF-8"%> <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %> <%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %> <%@ 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>JSP Page</title> </head> <body> <div style="color:red"> <html:errors /> </div> <html:form action="/login"> User Name : <html:text name="LoginForm" property="userName" /> <br> Password : <html:password name="LoginForm" property="password" /> <br> <html:submit value="login" /> </html:form> </body> </html>
failure.jsp
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 <%@page contentType="text/html" pageEncoding="UTF-8"%> <%@ taglib prefix="html" uri="http://struts.apache.org/tags-html" %> <%@ taglib prefix="logic" uri="http://struts.apache.org/tags-logic" %> <%@ taglib prefix="bean" uri="http://struts.apache.org/tags-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>JSP Page</title> </head> <body> <h1>Login Success. Welcome <bean:write name="LoginForm" property="userName"></bean:write></h1> <h1>user information <bean:write name="logininf" property="logininf"></bean:write></h1> </body> </html>
index2.jsp
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 <%@page contentType="text/html" pageEncoding="UTF-8"%> <%@ taglib prefix="html" uri="http://struts.apache.org/tags-html" %> <%@ taglib prefix="logic" uri="http://struts.apache.org/tags-logic" %> <%@ taglib prefix="bean" uri="http://struts.apache.org/tags-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>JSP Page</title> </head> <body> <div style="color:red"> <h1>Invalid user name <bean:write name="LoginForm" property="userName"></bean:write></h1> </div> </body> </html>
helloWorld.jsp
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4 <%@page contentType="text/html"%> <%@page pageEncoding="UTF-8"%> <jsp:forward page="helloworld.do"/>
struts-config.xml
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 <%@page contentType="text/html" pageEncoding="UTF-8"%> <%@ taglib prefix="html" uri="http://struts.apache.org/tags-html" %> <%@ taglib prefix="logic" uri="http://struts.apache.org/tags-logic" %> <%@ taglib prefix="bean" uri="http://struts.apache.org/tags-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>Hello World</title> </head> <body> <h1><bean:write name="HelloWorldAction" property="message"></bean:write></h1> </body> </html>
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
27
28
29
30
31 <?xml version="1.0" encoding="ISO-8859-1" ?> <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.3//EN" "http://struts.apache.org/struts/dtds/struts-config_1_3.dtd"> <struts-config> <form-beans> <form-bean name="loginForm " type="LoginForm "/> <form-bean name="helloWorldForm" type="HelloWorldForm"/> </form-beans> <action-mappings> <action input="/login.jsp" name="LoginForm" path="/login" scope="session" type="LoginAction"> <forward name="success" path="/success.jsp" /> <forward name="failure" path="/failure.jsp" /> </action> <action input="/index2.jsp" name="HelloWorldForm" path="/helloworld" scope="session" type="HelloWorldAction"> <forward name="success" path="/helloWorld.jsp" /> </action> </action-mappings> <message-resources parameter="ApplicationResource"/> </struts-config>
Partager