2012-08-07 77 views
1

我從這裏開始:如何從JSP頁面返回index.html(登錄頁面)?

enter image description here

與該代碼:

<!DOCTYPE html> 
<html> 
<head><title>Bank application</title> 
<link rel="stylesheet" 
     href="./css/styles.css" 
     type="text/css"/> 
</head> 
<body> 
<table class="title"> 
    <tr><th>Web Bank application</th></tr> 
</table> 

<br/> 
<fieldset> 
    <legend>Login Page - please enter your Username and Password</legend> 
    <form action="loginPage"> 
    Username: <input type="text" name="username"><br> 
    Password : <input type="text" name="password"><br> 
    <input type="submit" value="Login"> 
    </form> 
</fieldset> 

<br/> 
<br/> 
<br/> 

<fieldset> 
    <legend>Registration</legend> 
    <form action="register"> 
    First name: <input type="text" name="firstName"><br> 
    Last name : <input type="text" name="lastName"><br> 
    Address : <input type="text" name="address"><br> 
    ID-number : <input type="text" name="idnumber"><br> 
    User-Name : <input type="text" name="userName"><br> 
    Password : <input type="text" name="password"><br> 
    <input type="submit" value="Register"> 
    </form> 
</fieldset> 

<br/> 
<br/><br/><br/><br/><br/><br/> 
</body></html> 

雖然我從一個頁面移動到另一個,我來到這裏:

enter image description here

使用該密碼:

<!DOCTYPE html> 
<html> 
<head><title>Authentication failed - a problem has occurred!</title> 
<link rel="stylesheet" 
     href="./css/styles.css" 
     type="text/css"/> 
</head> 
<body> 
<h1>Sorry , but you are not registered to our bank!</h1> 

<fieldset> 
    <legend>Please press here to continue</legend> 
    <form action="goingBack"> 
    <input type="submit" value="Press here"> 
    </form> 
</fieldset> 

</body></html> 

我想回到index.html - 我在程序啓動時看到的第一頁(上面的第一張圖片)。

我該怎麼做?我怎樣才能轉回index.html

Regards

+0

你想提交按鈕用戶返回? – Tomer 2012-08-07 08:52:23

+0

@ ftom2:也許我會在未來需要,但現在我想重定向到'index.html'。 – 2012-08-07 08:53:02

回答

2

只需添加一個鏈接到前一頁的最後HTML:

<!DOCTYPE html> 
<html> 
<head><title>Authentication failed - a problem has occurred!</title> 
<link rel="stylesheet" 
     href="./css/styles.css" 
     type="text/css"/> 
</head> 
<body> 
<h1>Sorry , but you are not registered to our bank!</h1> 

<fieldset> 
    <legend>Please press here to continue</legend> 
    <form action="goingBack"> 
    <input type="submit" value="Press here"> 
    </form> 
</fieldset> 

<a href="index.jsp">Go Back</a> <!-- add this --> 

</body></html> 
+0

但爲什麼'index.jsp'而不是'index.html'? – 2012-08-07 08:54:46

+0

只是一個例子,在你可以把你喜歡的任何鏈接 – Tomer 2012-08-07 08:55:19

+0

+1,喜歡它。確實回答了答案! – 2012-08-07 08:56:10

1

您只需要JavaScript。重定向到/index.html 5秒後:

setTimeout('window.location='index.html';', 5000); 

setTimeout()是JavaScript函數,其設定一個定時器給定的時間段之後,以觸發服用點。 window.location是一個變量,允許您更改當前頁面的URL(因此重定向)。

+0

我在哪裏放?在一個servlet或JSP文件中? – 2012-08-07 08:48:56

+0

如果他不想在5秒後返回,但是用戶點擊該怎麼辦? – Tomer 2012-08-07 08:49:56

+0

@ ftom2如果它是一個按鈕點擊,這是不是在這裏精簡,我認爲這個問題應該被刪除,因爲它將顯示零研究和零他們正在做什麼的理解。基本上它會問如何進行鏈接.. – kgautron 2012-08-07 08:55:12