導航:首頁 > 編程語言 > java如何跳轉頁面跳轉

java如何跳轉頁面跳轉

發布時間:2024-05-31 04:16:16

❶ 在java web開發中,凡是能實現頁面跳轉的方法有哪些具體列出這些方法的實現語句

一、跳轉到新頁面,並且是在新窗口中打開頁面:
function openHtml()
{
//do someghing here...
window.open("xxxx.html");
}
window是一個javascript對象,可以用它的open方法,需要注意的是,如果這個頁面不是一相相對路徑,那麼要加「http://」,比如:
function openHtml()
{
window.open("http://www..com");
}

二、在本頁面窗口中跳轉:
function totest2()
{
window.location.assign("test2.html");
}
如果直接使用location.assgin()也可以,但是window.location.assign()更合理一些,當前窗口的location對象的assign()方法。
另外,location對象還有一個方法replace()也可以做頁面跳轉,它跟assign()方法的區別在於:
replace() 方法不會在 History 對象中生成一個新的紀錄。當使用該方法時,新的 URL 將覆蓋 History 對象中的當前紀錄。

❷ 用java做好的登陸界面,當登陸成功後跳轉到下個頁面的代碼是什麼

用java做好的登陸界面,當登陸成功後跳轉到下個頁面的代碼如下:
如果登陸驗證是在jsp中,那麼跳轉可以寫成
1.response.sendRedirct("跳轉到頁面");
2.<jsp:forward page="跳轉頁面"/>
3.response.setHeader("Location","");
如果是登陸驗證是在servlet中,那麼中轉可以寫成
1.response.sendRedirect("/a.jsp");
2.RequestDispatcher dispatcher = request.getRequestDispatcher("/a.jsp");
dispatcher .forward(request, response);
也可以使用js代碼實現:
<script>
function validate(){
window.location.href="/index.jsp";
}
</script>

❸ java程序中如何實現單擊頁面a中的按鈕跳轉到頁面b

java程序中的jsp頁面點擊按鈕跳轉到頁面b的方式如下:
1.jsp頁面的方式如下:<a href="....b.jsp">跳轉</a>
response.sendRedirect("b.jsp")
<jsp:forward page="b.jsp"/>
2.在swing里,給button加一個監聽器,然後在監聽事件中打開另一個頁面。
在jsp或是靜態網頁里,onclick=「JavaScript:window.location=』xx『」

❹ java中如何做到界面的跳轉

假如有兩個frame,分別為frame1,frame2,frame1加個按鈕實現跳轉.frame1代碼如下
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;

public class frame1 extends JFrame implements ActionListener{

/**
* @param args
*/
private JButton jb;
public frame1()
{
this.setSize(300, 200);
this.setLocation(300, 400);
jb=new JButton("跳轉");
this.add(jb);
jb.addActionListener(this);//加入事件監聽
this.setVisible(true);

}
public static void main(String[] args) {
// TODO Auto-generated method stub
frame1 frame=new frame1();

}
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if(e.getSource()==jb)
{
this.dispose();//點擊按鈕時frame1銷毀,new一個frame2
new frame2();
}
}

}

frame2是個單純的界面
import javax.swing.JButton;
import javax.swing.JFrame;

public class frame2 extends JFrame{

/**
* @param args
*/
public frame2()
{

this.setSize(300, 200);
this.setLocation(300, 400);

this.setVisible(true);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
frame2 frame=new frame2();
}

}

❺ 怎麼用java代碼控制html頁面跳轉

jsp中通過後台servlet是可以跳轉頁面的。 1、客戶端跳轉 // 使用response對象的sendRedirect實現客戶端跳轉 // servlet的doGet方法 public void doGet(HttpServletRequest req,HttpServletResponse res) throws ServletException,IOException {怎麼用java代碼控制html頁面跳轉

❻ 用java怎樣編寫登錄頁面,可以達到成功登錄後跳轉到下一個頁面

1、直接從web.xml中配置,直接跳轉到凳拍login.jsp登錄界面。


2、從index.jsp界鏈讓面進行JS跳棚粗局轉。

❼ 有關java中的界面跳轉

package com.sxt.bms.view;
import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
public class LoginFrame extends JFrame implements ActionListener {
private JPasswordField passwordField;
private JTextField textField;
/**
* Launch the application
* @param args
*/
public static void main(String args[]) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
LoginFrame frame = new LoginFrame();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame
*/
public LoginFrame() {
super();
setTitle("超MAN圖書管理系統");
setResizable(false);
getContentPane().setLayout(null);
setBounds(100, 100, 299, 295);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JLabel lblHeader= new JLabel();
lblHeader.setIcon(new ImageIcon("image/logo.JPG"));
lblHeader.setBounds(0, -1, 301, 100);
getContentPane().add(lblHeader);
final JLabel label = new JLabel();
label.setText("帳號");
label.setBounds(53, 132, 48, 18);
getContentPane().add(label);
textField = new JTextField();
textField.setBounds(107, 132, 159, 22);
getContentPane().add(textField);
final JLabel label_1 = new JLabel();
label_1.setText("密碼");
label_1.setBounds(53, 172, 48, 18);
getContentPane().add(label_1);
passwordField = new JPasswordField();
passwordField.setBounds(107, 172, 159, 22);
getContentPane().add(passwordField);
final JButton btnLogin = new JButton();
btnLogin.addActionListener(this);
btnLogin.setText("登錄");
btnLogin.setBounds(27, 210, 106, 28);
getContentPane().add(btnLogin);
final JButton btnCancel = new JButton();
btnCancel.setText("退出");
btnCancel.setBounds(171, 210, 106, 28);
getContentPane().add(btnCancel);
//
this.setLocationRelativeTo(null);
}
public void actionPerformed(final ActionEvent e) {
if(e.getActionCommand().equals("登錄")){
//資料庫判斷
MainFrame mainFrame=new MainFrame();
mainFrame.setVisible(true);

this.dispose();
}else if(e.getActionCommand().equals("退出")){
System.exit(0);
}
}
}

閱讀全文

與java如何跳轉頁面跳轉相關的資料

熱點內容
自己購買雲主伺服器推薦 瀏覽:422
個人所得稅java 瀏覽:761
多餘的伺服器滑道還有什麼用 瀏覽:192
pdf劈開合並 瀏覽:28
不能修改的pdf 瀏覽:752
同城公眾源碼 瀏覽:489
一個伺服器2個埠怎麼映射 瀏覽:298
java字元串ascii碼 瀏覽:79
台灣雲伺服器怎麼租伺服器 瀏覽:475
旅遊手機網站源碼 瀏覽:332
android關聯表 瀏覽:946
安卓導航無聲音怎麼維修 瀏覽:333
app怎麼裝視頻 瀏覽:431
安卓系統下的軟體怎麼移到桌面 瀏覽:96
windows拷貝到linux 瀏覽:772
mdr軟體解壓和別人不一樣 瀏覽:904
單片機串列通信有什麼好處 瀏覽:340
游戲開發程序員書籍 瀏覽:860
pdf中圖片修改 瀏覽:288
匯編編譯後 瀏覽:491