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);
}
}