0

ある JSP ページから別の JSP ページに移動しようとしていますが、ユーザーが名前とパスワードを入力しても同じページのままです。完全なコードは次のとおりです。

これが index.jsp です: このページから始めます

<%@ page language="java" contentType="text/html; charset=windows-1255"
    pageEncoding="windows-1255"%>
<!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=windows-1255">
<title>Insert title here</title>
</head>
<body>
<form action="LoginServlet" method="POST">
        First Name: <input type="text" name="firstName" size="20"><br>
        Last Name: <input type="text" name="lastName" size="20">
        <br><br>
        <input type="submit" value="Submit">
</form> 

</body>
</html>

これがstudent.jspです: このページに移動したい

<%@ page contentType="text/html; charset=utf-8" language="java"%>
<jsp:useBean id="userBean" class="UserBean" scope="session" />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet"  type="text/css" href="css/style2.css" />
<title>Student Access Details</title>
</head>

<body>
<table>
    <tr>
        <td rowspan="4" class="align_top"><img src="img/photo.jpg" width="120" height="120" /></td>
        <td class="align_top">Student name: </td>
        <td class="bold"><%= userBean.getFirstName() %> <%= userBean.getLastName() %></td>
    </tr>
    <tr>
        <td class="align_top">University ID: </td>
        <td><%= userBean.getUid() %></td>
    </tr>       
    <tr>
        <td class="align_top">Address: </td>
        <td><%= userBean.getAddress1() %><br />
            <%if(userBean.getAddress2() != null)
                {%>
                <%= userBean.getAddress2() %><br /><%}%>            
            <%= userBean.getCity() %><br />
            <%= userBean.getPostCode() %><br />
        </td>
    </tr>
    <tr>
        <td class="align_top">Contact: </td>
        <td>Tel: <%= userBean.getPhone() %><br />
            Email: <%= userBean.getEmail() %>
        </td>
    </tr>            
</table>
</body>
</html>

を使用してTomcat ,JDBC , XAMPP and MySQLいます。

ブラウザからこの行を実行すると:http://localhost:8080/MyFirstServlet

このページに入り、homer&を押しますsimpson:先頭ページ

次に、同じページにとどまります。

2枚目の写真 - 同じページ

私が間違っていることは何ですか?ありがとう !

4

2 に答える 2

1

あなたの validate(...) メソッドは、 homer と simpson に対して常に false を返します。他のユーザー名/パスワードを試してください

于 2012-07-01T14:59:00.403 に答える
0

HTMLフォームのHTMLコードアクションパラメーターで適切なアクションを使用して、フォームを送信する必要がある場所に送信します

アクションパラメータ値を変更して試す代わりに

<form action="LoginServlet" method="POST">

これを使って

<form action="student.jsp" method="POST">
于 2013-08-19T11:59:47.900 に答える