当我单击Java Script中的按钮时,如何调用函数(在另一个java类中)

时间:2015-02-20 09:43:44

标签: javascript html css

我正在尝试编写我的第一个Web应用程序,所以如果有任何愚蠢的错误/问题,请原谅

我正在尝试在我的Web应用程序页面中放置2个按钮,我想在eclipse中调用我的src目录中的类,我尝试导入该类,然后在按钮onclick方法中调用该函数,但这并不是&# 39;似乎工作很困惑,我不知道还有什么可以尝试

    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"pageEncoding="ISO-8859-1"%>   
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
            <title>Insert title here</title>
        </head>
        <link href="main.css" rel="stylesheet" type="text/css" />
            <body>
                <form action="">
                    <table>
                        <tr>
                            <td>UserName : </td>
                            <td>
                                <input type="text" name="userName" id="userName">
                            </td>
                        </tr>
                        <tr>
                            <td>Password : </td>
                            <td>
                                <input type="password" name="password" id="password">
                            </td>
                        </tr>
                        <tr>
                            <td>Build Number : </td>
                            <td>
                                <input type="text" name="buildNumber" id="buildNumber">
                            </td>
                        </tr>
                        <tr>
                            <td>Previous Build Number : </td>
                            <td>
                                <input type="text" name="perviousBuild" id="perviousBuild">
                            </td>
                        </tr>
                        <tr>
                            <td>Integ SCR</td>
                            <td>
                                <input type="text" id="integScr" name="IntegScr">
                            </td>
                        </tr>
                        <tr>
                            <td></td>
                        </tr>
                        <tr>
                            <td>
                                <input type="button" value="Test Connection" id="test" onclick="test()">
                            </td>
                            <td>
                                <input type="button" value="Start Build" id="start" onclick="start()">
                            </td>
                        </tr>
                    </table>
                </form>
            </body>
        </html>


This is the class that has java methods

public class OnClickTest {
    public void test()
    {
        System.out.println("Test");
    }
    public void start()
    {
        System.out.println("Start");
    }
}

0 个答案:

没有答案