-
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 #444 from CXCong/master
#4 提交实验代码
- Loading branch information
Showing
4 changed files
with
237 additions
and
0 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
jweb/src/edu/hzu/javaweb/labs/Se1414080902105/Se1414080902105filter.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,36 @@ | ||
|
||
|
||
import java.io.IOException; | ||
|
||
import javax.servlet.Filter; | ||
import javax.servlet.FilterChain; | ||
import javax.servlet.FilterConfig; | ||
import javax.servlet.ServletException; | ||
import javax.servlet.ServletRequest; | ||
import javax.servlet.ServletResponse; | ||
import javax.servlet.annotation.WebFilter; | ||
|
||
@WebFilter(filterName = "EncodingFilter", urlPatterns = "/*") | ||
|
||
public class EncodingFilter implements Filter { | ||
@Override | ||
public void destroy() { | ||
|
||
} | ||
|
||
@Override | ||
public void doFilter(ServletRequest request, ServletResponse response, | ||
FilterChain chain) throws IOException, ServletException { | ||
|
||
request.setCharacterEncoding("UTF-8"); | ||
|
||
response.setCharacterEncoding("UTF-8"); | ||
chain.doFilter(request, response); | ||
} | ||
|
||
@Override | ||
public void init(FilterConfig filterConfig) throws ServletException { | ||
|
||
} | ||
|
||
} |
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,47 @@ | ||
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> | ||
<% | ||
String path = request.getContextPath(); | ||
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; | ||
%> | ||
|
||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> | ||
<html> | ||
<head> | ||
<base href="<%=basePath%>"> | ||
|
||
<title>My JSP 'MyJsp.jsp' starting page</title> | ||
|
||
<meta http-equiv="pragma" content="no-cache"> | ||
<meta http-equiv="cache-control" content="no-cache"> | ||
<meta http-equiv="expires" content="0"> | ||
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> | ||
<meta http-equiv="description" content="This is my page"> | ||
<!-- | ||
<link rel="stylesheet" type="text/css" href="styles.css"> | ||
--> | ||
|
||
<head> | ||
<title>手机话费充值卡销售系统</title> | ||
</head> | ||
<body> | ||
|
||
<h2 align="center">手机话费充值卡销售系统</h2> | ||
<form> | ||
<table align="center"> | ||
<tr><td>充值号码:</td><td><input type="email" name="Email"></td></tr> | ||
<tr><td>充值金额:</td><td><input type="text" name="Name"></td></tr> | ||
<tr><td>充值卡账号:</td><td><input type="password" name="PW"></td></tr> | ||
<tr><td>充值卡密码:</td><td><input type="password" name="PW"></td></tr> | ||
|
||
</td> | ||
</tr> | ||
<tr> | ||
<td> | ||
<input type="submit" value="确定"> <input type="reset" value="取消"> | ||
</td> | ||
</tr> | ||
</table> | ||
</form> | ||
|
||
</body> | ||
<html> |
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,59 @@ | ||
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8> | ||
<% | ||
String path = request.getContextPath(); | ||
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; | ||
%> | ||
|
||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> | ||
<html> | ||
<head> | ||
<base href="<%=basePath%>"> | ||
|
||
<title>My JSP 'MyJsp.jsp' starting page</title> | ||
|
||
<meta http-equiv="pragma" content="no-cache"> | ||
<meta http-equiv="cache-control" content="no-cache"> | ||
<meta http-equiv="expires" content="0"> | ||
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> | ||
<meta http-equiv="description" content="This is my page"> | ||
<!-- | ||
<link rel="stylesheet" type="text/css" href="styles.css"> | ||
--> | ||
|
||
<head> | ||
<title>手机话费充值卡销售系统</title> | ||
</head> | ||
<body> | ||
|
||
<h2 align="center">手机话费充值卡销售系统</h2> | ||
<form> | ||
<table align="center"> | ||
<tr><td>充值号码:</td><td><input type="email" name="Email"></td></tr> | ||
<tr><td>充值金额:</td><td><input type="text" name="Name"></td></tr> | ||
<tr><td>充值卡账号:</td><td><input type="password" name="PW"></td></tr> | ||
<tr><td>充值卡密码:</td><td><input type="password" name="PW"></td></tr> | ||
|
||
</td> | ||
</tr> | ||
<tr> | ||
<td> | ||
<input type="submit" value="确定"> <input type="reset" value="取消"> | ||
</td> | ||
</tr> | ||
</table> | ||
</form> | ||
<script> | ||
$( "#target" ).submit(function( event ) { | ||
$.ajax({ | ||
url: "success.json" | ||
}).done(function(data) { | ||
if ( console && console.log ) { | ||
console.dir(data); | ||
alert(data.msg); | ||
} | ||
}); | ||
}); | ||
</script> | ||
</body> | ||
<html> |
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,95 @@ | ||
package edu.hzu.javaweb.labs.se1414080902205; | ||
|
||
import java.io.IOException; | ||
import java.io.PrintWriter; | ||
|
||
import javax.servlet.ServletException; | ||
import javax.servlet.annotation.WebServlet; | ||
import javax.servlet.http.HttpServlet; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
|
||
@WebServlet("/1414080902105") | ||
public class se1414080902105Selvet extends HttpServlet { | ||
|
||
/** | ||
* Constructor of the object. | ||
*/ | ||
public se1414080902105Selvet() { | ||
super(); | ||
} | ||
|
||
/** | ||
* Destruction of the servlet. <br> | ||
*/ | ||
public void destroy() { | ||
super.destroy(); // Just puts "destroy" string in log | ||
// Put your code here | ||
} | ||
|
||
/** | ||
* The doGet method of the servlet. <br> | ||
* | ||
* This method is called when a form has its tag value method equals to get. | ||
* | ||
* @param request the request send by the client to the server | ||
* @param response the response send by the server to the client | ||
* @throws ServletException if an error occurred | ||
* @throws IOException if an error occurred | ||
*/ | ||
public void doGet(HttpServletRequest request, HttpServletResponse response) | ||
throws ServletException, IOException { | ||
|
||
response.setContentType("text/html"); | ||
PrintWriter out = response.getWriter(); | ||
out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">"); | ||
out.println("<HTML>"); | ||
out.println(" <HEAD><TITLE>A Servlet</TITLE></HEAD>"); | ||
out.println(" <BODY>"); | ||
out.print(" This is "); | ||
out.print(this.getClass()); | ||
out.println(", using the GET method"); | ||
out.println(" </BODY>"); | ||
out.println("</HTML>"); | ||
out.flush(); | ||
out.close(); | ||
} | ||
|
||
/** | ||
* The doPost method of the servlet. <br> | ||
* | ||
* This method is called when a form has its tag value method equals to post. | ||
* | ||
* @param request the request send by the client to the server | ||
* @param response the response send by the server to the client | ||
* @throws ServletException if an error occurred | ||
* @throws IOException if an error occurred | ||
*/ | ||
public void doPost(HttpServletRequest request, HttpServletResponse response) | ||
throws ServletException, IOException { | ||
|
||
response.setContentType("text/html"); | ||
PrintWriter out = response.getWriter(); | ||
out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">"); | ||
out.println("<HTML>"); | ||
out.println(" <HEAD><TITLE>A Servlet</TITLE></HEAD>"); | ||
out.println(" <BODY>"); | ||
out.print(" This is "); | ||
out.print(this.getClass()); | ||
out.println(", using the POST method"); | ||
out.println(" </BODY>"); | ||
out.println("</HTML>"); | ||
out.flush(); | ||
out.close(); | ||
} | ||
|
||
/** | ||
* Initialization of the servlet. <br> | ||
* | ||
* @throws ServletException if an error occurs | ||
*/ | ||
public void init() throws ServletException { | ||
// Put your code here | ||
} | ||
|
||
} |