我们专注攀枝花网站设计 攀枝花网站制作 攀枝花网站建设
成都网站建设公司服务热线:400-028-6601

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

java项目代码范例,java项目实例源码

JAVA代码

public gongnengJF() {

创新互联网站建设提供从项目策划、软件开发,软件安全维护、网站优化(SEO)、网站分析、效果评估等整套的建站服务,主营业务为做网站、网站设计重庆APP开发以传统方式定制建设网站,并提供域名空间备案等一条龙服务,秉承以专业、用心的态度为用户提供真诚的服务。创新互联深信只要达到每一位用户的要求,就会得到认可,从而选择与我们长期合作。这样,我们也可以走得更远!

initComponents();

if(MessagePost.getUserPost().equals("职工")){

this.jMenuItem2.setEnabled(false);

里面initComponents什么意思setEnabled是什么?

/*

initComponents()

是你在使用GUI工具设计GUI界面时,NetBeans系统自动生成的方法。其功能是在界面添加各个组件,并为它们注册监听器。把initComponents()放在构造方法中,目的在于:在主类调用构造方法初始化时,完成了界面的绘制。

setEnabled(false)

是设置组件是否可用。

为false时,是不可用。

*/

private void jButton1MouseClicked(java.awt.event.MouseEvent evt) private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {

// TODO add your handling code here:

new pingcebumen().setVisible(true);

this.setVisible(false);

}

private void jButton2MouseClicked(java.awt.event.MouseEvent evt) {

// TODO add your handling code here:

String newpwd=javax.swing.JOptionPane.showInputDialog(rootPane, "输入新密码");

String sql="update renyuanlist password ="+newpwd+"where username ='"+MessagePost.getUserName()+"'";

Database db = new Database();

db.executeDML(sql);

}

private void jMenuItem1MouseClicked(java.awt.event.MouseEvent evt) {

// TODO add your handling code here:

new ziliao().setVisible(true);

String newpwd = null;

String sql="select * from renyuanlist where password ="+newpwd+"where username ='"+MessagePost.getUserName()+"'";

}

private void jMenu1MouseClicked(java.awt.event.MouseEvent evt) {

// TODO add your handling code here:

new ziliao().setVisible(true);

}

/**

* @param args the command line arguments

*/

public static void main(String args[]) {

java.awt.EventQueue.invokeLater(new Runnable() {

public void run() {

MessagePost.setUserPost("职工");

new gongnengJF().setVisible(true);

}

});

}

// Variables declaration - do not modify

//私有的成员属性,定义GUI图形界面的按钮,菜单等。

private javax.swing.JButton jButton1;

private javax.swing.JButton jButton2;

private javax.swing.JMenu jMenu1;

private javax.swing.JMenuBar jMenuBar1;

private javax.swing.JMenuItem jMenuItem1;

private javax.swing.JMenuItem jMenuItem2;

private javax.swing.JMenuItem jMenuItem3;

private javax.swing.JMenuItem jMenuItem4;

Swing是一组Java程序元件,它能够创建图象用户接口(GUI)元件,如按钮和滚动条,它们独立于特定操作系统的开窗口系统。Swing元件使用Java Foundation Classes(JFC)。

new gongnengJF().setVisible(true);

this.setVisible(false);

通过new 创建的对象,与this不是同一个对象。

鼠标监听事件,包括单击,双击等。。。

求一个50行左右的JAVA代码,最好每行带注释,谢谢啦

/*这个相当详细了.

程序也不算太难.而且给老师看的时候效果比较好.因为有图形化界面,又实现一个比较实用的功能.老师会比较高兴的.

建立一个文件名为Change.java就可以编译了*/

/*

* 这个程序实现输入身高算出标准体重,输入体重,算出身高的功能

*/

import java.awt.*; //导入相关类包,这才样使用相应awt图形界面的类

import java.awt.event.*;//同上

public class Change extends Frame { //定义一个类Change, 父类是Frame(图形界面的)

Button b = new Button("互查"); //创建一个按钮的对象b,显示为"互查"

Label l1 = new Label("身高(cm)");//创建一个lable.显示身高

Label l2 = new Label("体重(kg)");//创建一个lable 显示体重

double heigth, weigth; //定义变量

double x, y; //定义变量

TextField tf1 = new TextField(null, 10);//添加Text框

TextField tf2 = new TextField(null, 10);//添加Text框

public Change() {//类的构造函数,完成初始化

super("互查表");//创建窗口,标题为互查表

setLayout(new FlowLayout(FlowLayout.LEFT));//设置布局

add(l1);//把lable 身高放到window里

add(tf1);//把Text 框 放到窗口上

add(l2); //把lable 体重放到window里

add(tf2);//Test放到窗口里

add(b);//把button放到窗口上

pack();//自动放到窗口里排列上边的组件

setVisible(true);//可以让用户看到窗口

addWindowListener(new WindowAdapter() {//如果按 X, 关闭窗口

public void windowClosing(WindowEvent e) {

System.exit(0);

}

});

b.addActionListener(new ButtonListener());//添加button监听函数

}

class ButtonListener implements ActionListener {//实现click button时功能操作

public void actionPerformed(ActionEvent e) {//当click调用

if (tf1.getText()!=null) {//检查tf1 test 是否为空

try {//取异常

x = Double.parseDouble(tf1.getText());//字符转为double型

weigth = (x - 100) * 0.9;//算重量

tf2.setText("" + weigth);//显示重量

} catch (NumberFormatException ex) {

tf1.setText("");//如果输入不是数字,设为空

}

}

if (tf1.getText().equals("")==true){//tf1是否为空

y = Double.parseDouble(tf2.getText());//把tf2里的文本转为double 型 的

heigth = y / 0.9 + 100; //算身高根据重量

tf1.setText("" + heigth);}//显示身高

}

}

public static void main(String[] args) {//主函数,程序入口

new Change(); //建立类Change的对象,并调用他的构造函数Change().显示窗口

}

}

求JAVA小项目的完整代码

给你个做好了的Java的源程序的记事本,自己看看就行了的,不怎么难的···

import java.awt.*;

import java.awt.event.*;

import java.io.*;

import javax.swing.*;

public class MyNotepad implements ActionListener{

private JFrame frame=new JFrame("新记事本");

private JTextArea jta=new JTextArea();

private String result="";

private boolean flag=true;

private File f;

private JButton jb=new JButton("开始");

private JTextField jtf=new JTextField(15);

private JTextField jt=new JTextField(15);

private JButton jbt=new JButton("替换为");

private JButton jba=new JButton("全部替换");

private Icon ic=new ImageIcon("D:\\java课堂笔记\\GUI\\11.gif");

private String value;

private int start=0;

private JFrame jf=new JFrame("查找");

private JFrame jfc=new JFrame("替换");

@Override

public void actionPerformed(ActionEvent e) {

String comm=e.getActionCommand();

if("新建".equals(comm)){

if(!(frame.getTitle().equals("新记事本"))){

if(!flag){

write();

newNew();

}else{

JFileChooser jfc=new JFileChooser("D:\\java课堂笔记");

int returnVal = jfc.showDialog(null,"保存为");

if(returnVal == JFileChooser.APPROVE_OPTION) {//选择文件后再执行下面的语句,保证了程序的健壮性

f=jfc.getSelectedFile();

flag=false;

write();

}

}

}else if(!(jta.getText().isEmpty())){

JFileChooser jfc=new JFileChooser("D:\\java课堂笔记");

int returnVal = jfc.showDialog(null,"保存为");

if(returnVal == JFileChooser.APPROVE_OPTION) {//选择文件后再执行下面的语句,保证了程序的健壮性

f=jfc.getSelectedFile();

flag=false;

write();

newNew();

}

}else{

newNew();

}

}else if("打开".equals(comm)){

JFileChooser jfc=new JFileChooser("D:\\java课堂笔记");

jfc.setDialogType(JFileChooser.OPEN_DIALOG);

int returnVal = jfc.showOpenDialog(null);

if(returnVal == JFileChooser.APPROVE_OPTION) {//选择文件后再执行下面的语句,保证了程序的健壮性

f=jfc.getSelectedFile();

frame.setTitle(f.getName());

result=read();

flag=false;

value=result;

jta.setText(result);

}

}else if("保存".equals(comm)){

JFileChooser jfc=new JFileChooser("D:\\java课堂笔记");

if(flag){

int returnVal = jfc.showDialog(null,"保存为");

if(returnVal == JFileChooser.APPROVE_OPTION) {//选择文件后再执行下面的语句,保证了程序的健壮性

f=jfc.getSelectedFile();

flag=false;

write();

}

}else{

write();

}

}else if("另存".equals(comm)){

JFileChooser jfc=new JFileChooser("D:\\java课堂笔记");

int returnVal = jfc.showDialog(null,"另存");

if(returnVal == JFileChooser.APPROVE_OPTION) {//选择文件后再执行下面的语句,保证了程序的健壮性

f=jfc.getSelectedFile();

write();

}

}else if("退出".equals(comm)){

System.exit(0);

}else if("撤销".equals(comm)){

jta.setText(value);

}else if("剪切".equals(comm)){

value=jta.getText();

jta.cut();

}else if("复制".equals(comm)){

jta.copy();

}else if("粘贴".equals(comm)){

value=jta.getText();

jta.paste();

}else if("删除".equals(comm)){

value=jta.getText();

jta.replaceSelection(null);

}else if("全选".equals(comm)){

jta.selectAll();

}else if("查找".equals(comm)){

value=jta.getText();

jf.add(jtf,BorderLayout.CENTER);

jf.add(jb,BorderLayout.SOUTH);

jf.setLocation(300,300);

jf.pack();

jf.setVisible(true);

jf.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

}else if("替换".equals(comm)){

value=jta.getText();

GridLayout gl=new GridLayout(3,3);

JLabel jl1=new JLabel("查找内容:");

JLabel jl2=new JLabel("替换为:");

jfc.setLayout(gl);

jfc.add(jl1);

jfc.add(jtf);

jfc.add(jb);

jfc.add(jl2);

jfc.add(jt);

jfc.add(jbt);

JLabel jl3=new JLabel();

JLabel jl4=new JLabel();

jfc.add(jl3);

jfc.add(jl4);

jfc.add(jba);

jfc.setLocation(300,300);

jfc.pack();

jfc.setVisible(true);

jfc.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

}else if("版本".equals(comm)){

JDialog jd=new JDialog(frame,"关于对话框");

jd.setSize(200,200);

JLabel l=new JLabel("哈哈哈哈哈哈哈哈哈哈呵呵呵呵呵呵呵呵呵呵呵呵呵");

jd.add(l,BorderLayout.CENTER);

jd.setLocation(100,200);

jd.setSize(300,300);

jd.setVisible(true);

// jd.pack();

jd.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);

}else if("开始".equals(comm)||"下一个".equals(comm)){

String temp=jtf.getText();

int s=value.indexOf(temp,start);

if(value.indexOf(temp,start)!=-1){

jta.setSelectionStart(s);

jta.setSelectionEnd(s+temp.length());

jta.setSelectedTextColor(Color.GREEN);

start=s+1;

jb.setText("下一个");

// value=value.substring(s+temp.length());//不能截取字串

}else {

JOptionPane.showMessageDialog(jf, "查找完毕!", "提示", 0, ic);

jf.dispose();

}

}else if("替换为".equals(comm)){

String temp=jtf.getText();

int s=value.indexOf(temp,start);

if(value.indexOf(temp,start)!=-1){

jta.setSelectionStart(s);

jta.setSelectionEnd(s+temp.length());

jta.setSelectedTextColor(Color.GREEN);

start=s+1;

jta.replaceSelection(jt.getText());

}else {

JOptionPane.showMessageDialog(jf, "查找完毕!", "提示", 0, ic);

jf.dispose();

}

}else if("全部替换".equals(comm)){

String temp=jta.getText();

temp=temp.replaceAll(jtf.getText(), jt.getText());

jta.setText(temp);

}

}

public String read(){

String temp="";

try {

FileInputStream fis = new FileInputStream(f.getAbsolutePath());

byte[] b=new byte[1024];

while(true){

int num=fis.read(b);

if(num==-1)break;

temp=temp+new String(b,0,num);

}

fis.close();

} catch (Exception e1) {

e1.printStackTrace();

}

return temp;

}

public void write(){

try {

FileOutputStream fos=new FileOutputStream(f);

fos.write(jta.getText().getBytes());

fos.close();

} catch (Exception e) {

e.printStackTrace();

}

}

public void newNew(){

frame.dispose();

new MyNotepad();

flag=true;

}

public MyNotepad(){

JMenuBar jmb=new JMenuBar();

String[] menuLab={"文件","编辑","帮助"};

String[][] menuItemLab={{"新建","打开","保存","另存","退出"},

{"撤销","剪切","复制","粘贴","删除","全选","查找","替换"},

{"版本"}};

for(int i=0;imenuLab.length;i++){

JMenu menu=new JMenu(menuLab[i]);

jmb.add(menu);

for(int j=0;jmenuItemLab[i].length;j++){

JMenuItem jmi=new JMenuItem(menuItemLab[i][j]);

menu.add(jmi);

jmi.addActionListener(this);

}

}

frame.setJMenuBar(jmb);

jta.setLineWrap(true);//自动换行

JScrollPane jsp=new JScrollPane(jta);//滚动窗口面板

frame.add(jsp);

jb.addActionListener(this);

jbt.addActionListener(this);

jba.addActionListener(this);

frame.setLocation(200,50);

frame.setSize(620,660);

frame.setVisible(true);

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

}

public static void main(String[] args) {

new MyNotepad();

}

}

求java树形目录代码范例

给你一个。一共三个类。是个资源管理器的代码

// FileList.java

package tl.exercise.swing;

import java.awt.Color;

import java.awt.Component;

import javax.swing.JLabel;

import javax.swing.JList;

import javax.swing.ListCellRenderer;

import javax.swing.ListModel;

import javax.swing.event.ListDataListener;

public class FileList

extends JList {

// PathNode theNode;

FileListModel dataModel;

static final long serialVersionUID = 10;

public FileList() {

dataModel = new FileListModel();

setModel(dataModel);

this.setCellRenderer(new MyCellRenderer());

}

public void fireTreeSelectionChanged(I_fileSystem node) {

// Vector files = node.getFiles();

// theNode = node;

dataModel.setNode(node);

updateUI();

}

}

class FileListModel implements ListModel {

FileList theList;

I_fileSystem node;

char fileType = I_fileSystem.ALL;

public void setNode(I_fileSystem node) {

this.node = node;

}

public Object getElementAt(int index) {

if (node != null) {

return ((I_fileSystem) node).getChild(fileType, index);

} else {

return null;

}

}

public int getSize() {

if (node != null) {

return ((I_fileSystem) node).getChildCount(fileType);

} else {

return 0;

}

}

public void addListDataListener(ListDataListener l) {

}

public void removeListDataListener(ListDataListener l) {

}

}

class MyCellRenderer extends JLabel implements ListCellRenderer {

public MyCellRenderer() {

setOpaque(true);

}

public Component getListCellRendererComponent(

JList list,

Object value,

int index,

boolean isSelected,

boolean cellHasFocus)

{

FolderNode node = (FolderNode) value;

setIcon(node.getIcon());

setText(value.toString());

setBackground(isSelected ? Color.BLUE.darker().darker() : Color.WHITE);

setForeground(isSelected ? Color.WHITE : Color.BLACK);

return this;

}

}

package tl.exercise.swing;

//JExplorer.java

import java.awt.BorderLayout;

import java.awt.Dimension;

import java.awt.Toolkit;

import javax.swing.JFrame;

import javax.swing.JPanel;

import javax.swing.JScrollPane;

import javax.swing.JSplitPane;

import javax.swing.border.BevelBorder;

public class JExplorer {

public static void main(String[] args) {

// JFrame.setDefaultLookAndFeelDecorated(true);

JFrame frame = new JFrame();

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

frame.getContentPane().add(new UI(frame));

frame.pack();

Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();

int left = (screen.width - frame.getWidth()) / 2;

int top = (screen.height - frame.getHeight()) / 2;

frame.setLocation(left, top);

frame.setVisible(true);

}

}

class UI extends JPanel {

// implements I_menuHandler{

static final long serialVersionUID = 0l;

static int LEFT_WIDTH = 200;

static int RIGHT_WIDTH = 300;

static int WINDOW_HEIGHT = 300;

JFrame frame = null;

public UI(JFrame frame) {

// EmptyBorder eb = new EmptyBorder(1,1,1,1);

this.frame = frame;

setPreferredSize(new Dimension(800, 600));

setBorder(new BevelBorder(BevelBorder.LOWERED));

setLayout(new BorderLayout());

FileList list = new FileList();

FileTree tree = new FileTree(list);

tree.setDoubleBuffered(true);

list.setDoubleBuffered(true);

JScrollPane treeView = new JScrollPane(tree);

treeView.setPreferredSize(

new Dimension(LEFT_WIDTH, WINDOW_HEIGHT));

JScrollPane listView = new JScrollPane(list);

listView.setPreferredSize(

new Dimension(RIGHT_WIDTH, WINDOW_HEIGHT));

JSplitPane pane =

new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, treeView,

listView);

pane.setDividerLocation(300);

pane.setDividerSize(4);

// pane.setDoubleBuffered(true);

add(pane);

}

}

package tl.exercise.swing;

//FileTree.java

/***********************************************************

* Author: Jason

* email: tl21cen@hotmail.com

* CSDN blog:

***********************************************************/

import java.awt.Component;

import java.io.File;

import java.util.Vector;

import javax.swing.Icon;

import javax.swing.JTree;

import javax.swing.event.TreeExpansionEvent;

import javax.swing.event.TreeExpansionListener;

import javax.swing.event.TreeModelListener;

import javax.swing.event.TreeSelectionEvent;

import javax.swing.event.TreeSelectionListener;

import javax.swing.filechooser.FileSystemView;

import javax.swing.tree.DefaultTreeCellRenderer;

import javax.swing.tree.TreeModel;

import javax.swing.tree.TreePath;

public class FileTree extends JTree {

static final long serialVersionUID = 0;

private FileList theList;

public FileTree(FileList list) {

theList = list;

setModel(new FileSystemModel(new FolderNode()));

this.setCellRenderer(new FolderRenderer());

addTreeSelectionListener(new TreeSelectionListener() {

public void valueChanged(TreeSelectionEvent tse) {

}

});

this.setSelectionRow(0);

}

public void fireValueChanged(TreeSelectionEvent tse) {

TreePath tp = tse.getNewLeadSelectionPath();

Object o = tp.getLastPathComponent();

// theList.fireTreeSelectionChanged((PathNode)o);

theList.fireTreeSelectionChanged((FolderNode) o);

}

public void fireTreeCollapsed(TreePath path) {

super.fireTreeCollapsed(path);

TreePath curpath = getSelectionPath();

if (path.isDescendant(curpath)) {

setSelectionPath(path);

}

}

public void fireTreeWillExpand(TreePath path) {

System.out.println("Path will expand is " + path);

}

public void fireTreeWillCollapse(TreePath path) {

System.out.println("Path will collapse is " + path);

}

class ExpansionListener implements TreeExpansionListener {

FileTree tree;

public ExpansionListener(FileTree ft) {

tree = ft;

}

public void treeCollapsed(TreeExpansionEvent tee) {

}

public void treeExpanded(TreeExpansionEvent tee) {

}

}

}

class FileSystemModel implements TreeModel {

I_fileSystem theRoot;

char fileType = I_fileSystem.DIRECTORY;

public FileSystemModel(I_fileSystem fs) {

theRoot = fs;

}

public Object getRoot() {

return theRoot;

}

public Object getChild(Object parent, int index) {

return ((I_fileSystem) parent).getChild(fileType, index);

}

public int getChildCount(Object parent) {

return ((I_fileSystem) parent).getChildCount(fileType);

}

public boolean isLeaf(Object node) {

return ((I_fileSystem) node).isLeaf(fileType);

}

public int getIndexOfChild(Object parent, Object child) {

return ((I_fileSystem) parent).getIndexOfChild(fileType, child);

}

public void valueForPathChanged(TreePath path, Object newValue) {

}

public void addTreeModelListener(TreeModelListener l) {

}

public void removeTreeModelListener(TreeModelListener l) {

}

}

interface I_fileSystem {

final public static char DIRECTORY = 'D';

final public static char FILE = 'F';

final public static char ALL = 'A';

public Icon getIcon();

public I_fileSystem getChild(char fileType, int index);

public int getChildCount(char fileType);

public boolean isLeaf(char fileType);

public int getIndexOfChild(char fileType, Object child);

}

/**

* A data model for a JTree. This model explorer windows file system directly.

*

* p

* Perhaps there is a fatal bug with this design. For speed, each of instances

* of this model contains file objects of subdirectory, up to now, there isn't

* any method to release them until program be end. I'm afraid that the memory

* would be full of if the file system is large enough and JVM memery size

* setted too small.

*

* p

* I won't pay more attention to solve it. it isn't goal of current a exercise.

*

* @author Jason

*/

class FolderNode implements I_fileSystem {

// private static FolderNode theRoot;

private static FileSystemView fsView;

private static boolean showHiden = true;;

private File theFile;

private VectorFile all = new VectorFile();

private VectorFile folder = new VectorFile();

/**

* set that whether apply hiden file.

*

* @param ifshow

*/

public void setShowHiden(boolean ifshow) {

showHiden = ifshow;

}

public Icon getIcon() {

return fsView.getSystemIcon(theFile);

}

public String toString() {

// return fsView.

return fsView.getSystemDisplayName(theFile);

}

/**

* create a root node. by default, it should be the DeskTop in window file

* system.

*

*/

public FolderNode() {

fsView = FileSystemView.getFileSystemView();

theFile = fsView.getHomeDirectory();

prepareChildren();

}

private void prepareChildren() {

File[] files = fsView.getFiles(theFile, showHiden);

for (int i = 0; i files.length; i++) {

all.add(files[i]);

if (files[i].isDirectory()

!files[i].toString().toLowerCase().endsWith(".lnk")) {

folder.add(files[i]);

}

}

}

private FolderNode(File file) {

theFile = file;

prepareChildren();

}

public FolderNode getChild(char fileType, int index) {

if (I_fileSystem.DIRECTORY == fileType) {

return new FolderNode(folder.get(index));

} else if (I_fileSystem.ALL == fileType) {

return new FolderNode(all.get(index));

} else if (I_fileSystem.FILE == fileType) {

return null;

} else {

return null;

}

}

public int getChildCount(char fileType) {

if (I_fileSystem.DIRECTORY == fileType) {

return folder.size();

} else if (I_fileSystem.ALL == fileType) {

return all.size();

} else if (I_fileSystem.FILE == fileType) {

return -1;

} else {

return -1;

}

}

public boolean isLeaf(char fileType) {

if (I_fileSystem.DIRECTORY == fileType) {

return folder.size() == 0;

} else if (I_fileSystem.ALL == fileType) {

return all.size() == 0;

} else if (I_fileSystem.FILE == fileType) {

return true;

} else {

return true;

}

}

public int getIndexOfChild(char fileType, Object child) {

if (child instanceof FolderNode) {

if (I_fileSystem.DIRECTORY == fileType) {

return folder.indexOf(((FolderNode) child).theFile);

} else if (I_fileSystem.ALL == fileType) {

return all.indexOf(((FolderNode) child).theFile);

} else if (I_fileSystem.FILE == fileType) {

return -1;

} else {

return -1;

}

} else {

return -1;

}

}

}

class FolderRenderer extends DefaultTreeCellRenderer {

private static final long serialVersionUID = 1L;

public Component getTreeCellRendererComponent(JTree tree, Object value,

boolean sel, boolean expanded, boolean leaf, int row,

boolean hasFocus) {

I_fileSystem node = (I_fileSystem) value;

Icon icon = node.getIcon();

setLeafIcon(icon);

setOpenIcon(icon);

setClosedIcon(icon);

return super.getTreeCellRendererComponent(tree, value, sel, expanded,

leaf, row, hasFocus);

}

}

java项目 代码结构说明书怎么写

接口文档,代码层次(比如公共方法写在哪个class里),哪些为一大类在一个包下,数据字典,就是介绍你这个项目的架构让后来的人怎么能容易参与开发,交接什么看这个就可以方便些,辅助作用的一个文档一般都是项目经理写

给我一个在html里面调用java类(Java代码)的范例,用javascript调用java类啊

如果你只是测试java类中的一个方法的话,新建java-web项目

写一个无返回值的方法。

在web默认启动的jsp页面添加以下内容:

!-- 导Jquery包 --

script src="js/project/jquery-1.7.2.min.js"/script

script type="text/javascript"

$(function(){

$.ajax({

url:"你的方法路径(在web.xml文件中配的访问路径)",

data:{},    //参数json格式

success:function(data){

alert(data);   //data就是执行方法后返回来的值

}

});

})

/script

如果你的java类方法中没有用PrintWriter.print()方法就不会弹出信息,但是你把断点打在测试的方法里面,如果路径是对,启动项目后进入调试模式说明已经进入方法。


本文名称:java项目代码范例,java项目实例源码
网页链接:http://shouzuofang.com/article/hdiscj.html

其他资讯