1. Form form submission:
<form action= "Http://localhost:8080/test/Login" method= "POST" >
User: <input type= "text" name= "username"/><br/>
Password: <input type= "password" name= "password"/><br/>
<input type= "Submit" value= "Login"/>
</form>
2, JS submitted:
(1) Added: <script type= "Text/javascript" src= "Assets/jquery-2.1.1.js" ></SCRIPT>, can be used in other, note to have $.post, some version does not ;
(2) var test={
Name: "Me",
Password: "Password"
};
$.post ("Http://localhost:8080/test/Login",
Test, function (text, status) {alert (text);});
3, Form+js submit:
The button in the form tag must be added: type= "button", followed by the same as above 2;
4. Server:
The Dopost () method in the Java class that inherits HttpServlet:
Request.setcharacterencoding ("UTF-8");
Response.setcharacterencoding ("UTF-8");
SYSTEM.OUT.PRINTLN ("Connect to Server" +request. GetParameter ("name") + "," +request. GetParameter ("Password" ));
Add Database Operations Database
PrintWriter out = response. getwriter ();
Out.write ("link Server success!"); //Return data to page
Out.close ();
The
Front-end form label sends a POST request, and the server inherits HttpServlet with the Java class and returns the data