1、用java如何後台獲得每一頁網頁的源代碼
必須的,如果你跳過他的攔截器,直接訪問它的頁面,那就不安全了,在設計的時候就是這么設計的
2、求個Java web的課程網站設計源碼(能運行的)有論文更好。。有重謝!
你這個題目,不管知網也好!
萬方學術論壇也好!
都有很多類似的,甚至內百度文庫都有不少的容!
給你個類似的改改吧!
==================論文寫作方法===========================
論文網上沒有免費的,與其花人民幣,還不如自己寫,萬一碰到騙人的,就不上算了。
寫作論文的簡單方法,首先大概確定自己的選題,然後在網上查找幾份類似的文章,通讀一遍,對這方面的內容有個大概的了解!
參照論文的格式,列出提綱,補充內容,實在不會,把這幾份論文綜合一下,從每篇論文上復制一部分,組成一篇新的文章!
然後把按自己的語言把每一部分換下句式或詞,經過換詞不換意的辦法處理後,網上就查不到了,祝你順利完成論文!
3、JAVA中GUI登錄界面設計源代碼是什麼?
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.FlowLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
public class Login {
private JFrame frame = new JFrame("登錄");
private Container c = frame.getContentPane();
private JTextField username = new JTextField();
private JPasswordField password = new JPasswordField();
private JButton ok = new JButton("確定");
private JButton cancel = new JButton("取消");
public Login(){
frame.setSize(300,200);
c.setLayout(new BorderLayout());
initFrame();
frame.setVisible(true);
}
private void initFrame() {
//頂部
JPanel titlePanel = new JPanel();
titlePanel.setLayout(new FlowLayout());
titlePanel.add(new JLabel("系統管理員登錄"));
c.add(titlePanel,"North");
//中部表單
JPanel fieldPanel = new JPanel();
fieldPanel.setLayout(null);
JLabel l1 = new JLabel("用戶名:");
l1.setBounds(50, 20, 50, 20);
JLabel l2 = new JLabel("密 碼:");
l2.setBounds(50, 60, 50, 20);
fieldPanel.add(l1);
fieldPanel.add(l2);
username.setBounds(110,20,120,20);
password.setBounds(110,60,120,20);
fieldPanel.add(username);
fieldPanel.add(password);
c.add(fieldPanel,"Center");
//底部按鈕
JPanel buttonPanel = new JPanel();
buttonPanel.setLayout(new FlowLayout());
buttonPanel.add(ok);
buttonPanel.add(cancel);
c.add(buttonPanel,"South");
}
public static void main(String[] args){
new Login();
}
}
4、JAVA 網站源代碼
您好, 我這有很多基於javaweb技術的在線網站, 比如個人博客系統, 學生管理系統, 學籍管理系統, 主要是用來做畢業設計和課程設計的, 如果是想商業話用途的話還是得自己找人搞
這些項目部分帶論文, 大部分採用springmvc+spring+mybatis的技術架構進行實現,也有純jsp+servlet實現的, 資料庫選用mysql, 按照mvc設計模式來實現, 還是很容易看懂的
5、JAVA中登錄窗口設計,源代碼該怎麼寫?
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Test_Login extends javax.swing.JFrame {
private JPanel jPanel1;
private JButton bntLogin;
private JButton bntCannel;
private JPasswordField pwd;
private JTextField username;
private JLabel jLabel2;
private JLabel jLabel1;
public static void main(String[] args) {
Test_Login inst = new Test_Login();
inst.setLocationRelativeTo(null);
inst.setVisible(true);
}
public Test_Login() {
super();
initGUI();
}
private void initGUI() {
try {
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
{
jPanel1 = new JPanel();
getContentPane().add(jPanel1, BorderLayout.CENTER);
jPanel1.setLayout(null);
{
jLabel1 = new JLabel();
jPanel1.add(jLabel1);
jLabel1.setText("用戶名");
jLabel1.setBounds(45, 30, 75, 25);
}
{
jLabel2 = new JLabel();
jPanel1.add(jLabel2);
jLabel2.setText("密碼");
jLabel2.setBounds(45, 75, 55, 15);
}
{
username = new JTextField();
jPanel1.add(username);
username.setBounds(100, 30, 140, 25);
}
{
pwd = new JPasswordField();
jPanel1.add(pwd);
pwd.setBounds(100, 70, 140, 25);
}
{
bntLogin = new JButton();
jPanel1.add(bntLogin);
bntLogin.setText("登陸");
bntLogin.setBounds(40, 120, 60, 30);
bntLogin.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
if (username.getText().equals("lisong")
&& pwd.getText().equals("lisong")) {
JOptionPane.showMessageDialog(Test_Login.this,
"登錄成功");
} else {
JOptionPane.showMessageDialog(Test_Login.this,
"登錄失敗");
}
}
});
bntCannel = new JButton();
jPanel1.add(bntCannel);
bntCannel.setText("取消");
bntCannel.setBounds(180, 120, 60, 30);
bntCannel.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
System.exit(0);
}
});
}
}
pack();
setSize(300, 215);
} catch (Exception e) {
e.printStackTrace();
}
}
}
6、java圖形界面設計實驗,求源代碼,謝謝大佬!
代碼:
import java.awt.*;
import javax.swing.*;
public class W extends JFrame
{
public static void main(String[] args)
{
內new W();
}
W()
{
JPanel p=new JPanel();
JButton b=new JButton("ok");
b.addActionListener(e->
{
b.setForeground(Color.BLUE);
b.setText("滑鼠點擊!容");
//setTitle("滑鼠點擊!");
});
p.add(b);
add(p,BorderLayout.NORTH);
setTitle("事件測試窗口");
setSize(200,150);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
}
}
運行結果截圖:
7、高分求兩個簡單的JAVA設計源代碼
我寫的是第一題,不知道行不行。
代碼寫在一個Java文件中:
import java.util.*;
public class Student implements Comparator
{
private String stuNo; //學號
private String name; //姓名
private double engScore; //英語成績
private double mathScore; //數學成績
private double comScore; //計算機成績
private double sum; //總成績
//計算評測成績
public double testScore(){
return (this.getEngScore()+this.getMathScore()+this.getComScore())/3;
}
//計算總成績
public double sum(){
return this.getEngScore()+this.getMathScore()+this.getComScore();
}
//實現compare方法
public int compare(Object object1,Object object2){
Student student1 = (Student)object1;
Student student2 = (Student)object2;
return student1.getSum() > student2.getSum() ? 1 : student1.getSum() < student2.getSum() ? -1 : 0 ;
}
//重寫toString方法
public String toString(){
return "學號:"+this.getStuNo()+" 姓名:"+this.getName()+" 英語成績:"+this.getEngScore()+" 數學成績:"+this.getMathScore()+" 計算機成績:"+this.getComScore()+" 總成績:"+this.getSum();
}
//重寫equals方法
public boolean equals(Object object){
if(object == null){
return false;
}
if(!(object instanceof Student)){
return false;
}
Student student = (Student)object;
if(student.getStuNo().equals(this.getStuNo()) && student.getName().equals(this.getName()) && student.getEngScore() == this.getEngScore() && student.getMathScore() == this.getMathScore() && student.getComScore() == this.getComScore() && student.getSum() == this.getSum()){
return true;
}
return true;
}
//getter和setter方法
public void setStuNo(String stuNo){
this.stuNo = stuNo;
}
public void setName(String name){
this.name = name;
}
public void setEngScore(double engScore){
this.engScore = engScore;
this.sum = this.sum();
}
public void setMathScore(double mathScore){
this.mathScore = mathScore;
this.sum = this.sum();
}
public void setComScore(double comScore){
this.comScore = comScore;
this.sum = this.sum();
}
public void setSum(double sum){
this.sum = sum;
}
public String getStuNo(){
return stuNo;
}
public String getName(){
return name;
}
public double getEngScore(){
return engScore;
}
public double getMathScore(){
return mathScore;
}
public double getComScore(){
return comScore;
}
public double getSum(){
return sum;
}
//無參構造方法
public Student(){}
//有參構造方法
public Student(String stuNo,String name,double engScore,double mathScore,double comScore){
this.stuNo = stuNo;
this.name = name;
this.engScore = engScore;
this.mathScore = mathScore;
this.comScore = comScore;
}
public Student(String stuNo,String name,double engScore,double mathScore,double comScore,double sum){
this(stuNo,name,engScore,mathScore,comScore);
this.sum = sum;
}
}
//班長子類
class StudentBZ extends Student
{
private String ty;//責任
public StudentBZ(){}
public StudentBZ(String stuNo,String name,double engScore,double mathScore,double comScore){
super(stuNo,name,engScore,mathScore,comScore);
}
public StudentBZ(String stuNo,String name,double engScore,double mathScore,double comScore,double sum){
super(stuNo,name,engScore,mathScore,comScore,sum);
}
public String getDuty(){
return ty;
}
public void setDuty(String ty){
this.ty = ty;
}
//重寫testScore方法
public double testScore(){
return (this.getEngScore()+this.getMathScore()+this.getComScore())/3 + 5;
}
}
//學委子類
class StudentXW extends Student
{
private String ty;//責任
public String getDuty(){
return ty;
}
public void setDuty(String ty){
this.ty = ty;
}
public StudentXW(String stuNo,String name,double engScore,double mathScore,double comScore){
super(stuNo,name,engScore,mathScore,comScore);
}
public StudentXW(String stuNo,String name,double engScore,double mathScore,double comScore,double sum){
super(stuNo,name,engScore,mathScore,comScore,sum);
}
//重寫testScore方法
public double testScore(){
return (this.getEngScore()+this.getMathScore()+this.getComScore())/3 + 3;
}
}
//測試類
class Test
{
public static void main(String[] args){
//Student(String stuNo,String name,double engScore,double mathScore,double comScore,double sum)
//生成若干個student類、StudentXW類、StudentBZ類
Student student1 = new Student("s001","張三",70.5,50,88.5);
Student student2 = new Student("s002","李四",88,65,88.5);
Student student3 = new Student("s003","王五",67,77,90);
StudentXW student4 = new StudentXW("s004","李六",99,88,99.5);
StudentBZ student5 = new StudentBZ("s005","朱漆",56,65.6,43.5);
Student[] students = {student1,student2,student3,student4,student5};
for(int i = 0 ; i<students.length; i++){
double avgScore = students[i].testScore();
System.out.println("第"+(i+1)+"個學生的評測成績為:"+ avgScore+"分");
}
}
}
8、設計一個JAVA程序,下載由URL指定的網頁的源代碼,找出其中所有的超鏈接。
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
public class HttpViewer extends JFrame {
private JTextField urlInput;
private JTextArea viewArea;
public static void main(String[] args) {
new HttpViewer();
}
public HttpViewer() {
this.setTitle("Http Viewer");
this.setSize(800, 600);
this.setResizable(false);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
initPanel();
initAction();
this.setVisible(true);
}
// 這個方法用來設置窗口布局
private void initPanel() {
JPanel northPanel = new JPanel();
JLabel urlInputLabel = new JLabel("URL:");
urlInput = new JTextField(60);
northPanel.add(urlInputLabel);
northPanel.add(urlInput);
this.add(northPanel, BorderLayout.NORTH);
JPanel centerPanel = new JPanel();
viewArea = new JTextArea(27, 60);
centerPanel.add(new JScrollPane(viewArea));
this.add(centerPanel);
}
// 這個方法用來設置事件
private void initAction() {
urlInput.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String text = urlInput.getText();
if (text == null || text.length() == 0) {
viewArea.setText("您沒有輸入URL");
return;
}
try {
URL url = new URL(text);
String context = getContent(url);
if (context != null) {
searchFromText(context);
}
} catch (MalformedURLException e1) {
viewArea.setText("您輸入的URL不合法:" + text);
}
}
});
}
private String getContent(URL url) {
StringBuffer builder = new StringBuffer();
int responseCode = -1;
HttpURLConnection con = null;
try {
con = (HttpURLConnection) url.openConnection();
con.setRequestProperty("User-Agent",
"Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)");// IE代理進行下載
con.setConnectTimeout(60000);
con.setReadTimeout(60000);
// 獲得網頁返回信息碼
responseCode = con.getResponseCode();
if (responseCode == -1) {
viewArea.setText("連接失敗:" + url.toString());
return null;
}
if (responseCode >= 400) {
viewArea.setText("請求失敗,錯誤碼:" + responseCode);
return null;
}
InputStream is = con.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String str = null;
while ((str = br.readLine()) != null)
builder.append(str);
is.close();
} catch (IOException e) {
e.printStackTrace();
viewArea.setText("IOException: " + url.toString());
} finally {
con.disconnect();
}
return builder.toString();
}
private void searchFromText(String context) {
viewArea.setText("查找URL中:
");
Pattern pattern = Pattern.compile("<a( [^>]+)*>(.*?)</a>");
Matcher matcher = pattern.matcher(context);
while (matcher.find()) {
for (String prop : matcher.group(1).split(" ")) {
int indexOf = prop.indexOf('=');
if (indexOf > 0) {
if (prop.substring(0, indexOf).equals("href")) {
String url2 = prop.substring(indexOf + 2, prop.length() - 1);
viewArea.append(url2 + "
");
}
}
}
}
}
}
9、javaweb 如何在頁面查看網頁源代碼和頁面顯示的內容一樣
請老哥遵守web協議,js在伺服器上,不給你看,全扣走,還玩個毛。
不過,你可以看一下js鏈接是否可以訪問,可以的話你就看,看不了就算了。ping ping ping
10、100分求 JAVA編寫的網頁源碼讀取工具
// 輸入URL 地址就可以讀取源碼...
......右鍵查看源代碼.不是要寫..是系統自帶的..誰的沒有這個功能..
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
public class Test extends JFrame {
private JTextField tURL = new JTextField("");
//顯示網頁的源代碼的多行文本
private JTextArea tPage = new JTextArea();
private BufferedReader reader;
public Test(String title)
{
super(title);
tPage.setEditable(false);
this.getContentPane().add(tURL,BorderLayout.NORTH);
this.getContentPane().add(new JScrollPane(tPage),BorderLayout.CENTER);
//注冊動作事件偵聽其
tURL.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae){
try{
//讀取web網頁
readPage(new URL(tURL.getText()));
}catch(MalformedURLException ke){
tPage.setText("URL錯誤");
}
}
});
}
// 讀取url對象所引用的web頁
void readPage(URL url)
{
tPage.setText("");
String line;
try{
//獲取url輸入流
reader = new BufferedReader(new InputStreamReader(url.openStream()));
//reader = new BufferedReader(new InputStreamReader(url.openConnection().getInputStream()));
//讀取一行,並添加至tPage中
while((line=reader.readLine())!=null)
tPage.append(line+"\n");
}catch(IOException ie){
tPage.setText("發生輸入輸出異常 ");
}finally{
try{
if(reader!=null)reader.close();
}catch(Exception e){}
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Test me = new Test("Page Viewer ");
me.setSize(400,400);
me.setVisible(true);
me.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}