-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #295 from OctRstar/master
#4 提交实验代码
- Loading branch information
Showing
2 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
jweb/src/edu/hzu/javaweb/labs/se1414080902215/Se1414080902215Servlet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package edu.hzu.javaweb.labs.se1414080902215; | ||
|
||
import java.io.IOException; | ||
import java.io.PrintWriter; | ||
|
||
import javax.servlet.RequestDispatcher; | ||
import javax.servlet.ServletException; | ||
import javax.servlet.http.HttpServlet; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
|
||
public class Se1414080902215Servlet extends HttpServlet { | ||
|
||
public void doGet(HttpServletRequest request, HttpServletResponse response) | ||
throws ServletException, IOException { | ||
doPost(request, response); | ||
|
||
} | ||
|
||
public void doPost(HttpServletRequest request, HttpServletResponse response) | ||
throws ServletException, IOException { | ||
response.setContentType("text/html"); | ||
PrintWriter out = response.getWriter(); | ||
out.println("You're already to submit! "); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<%@ 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> | ||
<script src="http://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script> | ||
</head> | ||
<body align="center"> | ||
<%= new java.util.Date() %> | ||
<form id="tijiao"> | ||
<div class="form-group"> | ||
<label for="user">User:</label> | ||
<input type="text" class="form-control" id="user" name="username" placeholder="user"> | ||
</div> | ||
<div class="form-group"> | ||
<label for="Password">Password:</label> | ||
<input type="password" class="form-control" id="Password" name="password" placeholder="Password"> | ||
</div> | ||
|
||
<button type="submit" class="btn btn-default">submit</button> | ||
</form> | ||
<script> | ||
$( "#tijiao" ).submit(function() { | ||
$.ajax({ | ||
url: "Se1414080902215Servlet", | ||
datatype:"text/html", | ||
type: "post", | ||
success: function(data){ | ||
alert(data); | ||
}}); | ||
}); | ||
</script> | ||
</body> | ||
</html> |