forked from hzuapps/java-web
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f1317fb
commit 9697ce4
Showing
3 changed files
with
138 additions
and
0 deletions.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
jweb/src/edu/hzu/javaweb/labs/se1414080902220/FirstSevlet.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,61 @@ | ||
package se1414080902220Servlet; | ||
import java.io.IOException; | ||
import java.io.PrintWriter; | ||
import javax.servlet.RequestDispatcher; | ||
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(urlPatterns="/1414080902220") | ||
public class FirstSevlet extends HttpServlet { | ||
|
||
public FirstSevlet() { | ||
super(); | ||
} | ||
|
||
|
||
public void destroy() { | ||
super.destroy(); | ||
} | ||
|
||
|
||
public void doGet(HttpServletRequest request, HttpServletResponse response) | ||
throws ServletException, IOException { | ||
|
||
|
||
} | ||
|
||
|
||
public void doPost(HttpServletRequest request, HttpServletResponse response) | ||
throws ServletException, IOException { | ||
String income=request.getParameter("income"); | ||
String timeString=request.getParameter("time"); | ||
String description=request.getParameter("description"); | ||
String message=new String(); | ||
try { | ||
Double incomeMoney=Double.parseDouble(income); | ||
if (incomeMoney<0) | ||
{ | ||
message="收入不允许为空"; | ||
} | ||
else | ||
{ | ||
message="添加收入成功"; | ||
} | ||
} catch (Exception e) { | ||
message="填写的收入不合法,请返回重新填写"; | ||
System.out.print(e.getMessage()); | ||
} | ||
request.setAttribute("res", message); | ||
RequestDispatcher rd=request.getRequestDispatcher("1414080902220/result.jsp"); | ||
rd.forward(request, response); | ||
|
||
} | ||
|
||
|
||
public void init() 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,56 @@ | ||
<%@ 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%>"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.0/css/bootstrap.min.css"> | ||
<script src="http://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script> | ||
<script src="http://cdn.bootcss.com/bootstrap/3.3.0/js/bootstrap.min.js"></script> | ||
<title>统计收入</title> | ||
<style type="text/css"> | ||
body{ | ||
background:#666; | ||
} | ||
input{ | ||
background-color: #777; | ||
border:none; | ||
border-radius:10px; | ||
text-align:center; | ||
} | ||
#div1{ | ||
padding: 10% 10% 10% 10%; | ||
} | ||
textarea{ | ||
background-color: #777; | ||
border:none; | ||
border-radius:10px; | ||
} | ||
</style> | ||
|
||
|
||
</head> | ||
|
||
<body> | ||
<br/><br/><br/><br/> | ||
<div class="col-md-2"></div> | ||
<div class="col-md-8" id="div1"> | ||
<form action="1414080902220" method="post"> | ||
<label for="income"> 收入:</label> | ||
<input type="text" name="income" id="income"><br/><br/> | ||
<label for="time"> 时间:</label> | ||
<input type="text" name="time"><br/><br/> | ||
<label for="texts">来源:</label> | ||
<input type="text" name="description" id="texts"><br/><br/> | ||
<input type="submit" value="添加"> | ||
</form> | ||
</div> | ||
<div class="col-md-2"></div> | ||
|
||
</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,21 @@ | ||
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> | ||
<% | ||
String path = request.getContextPath(); | ||
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; | ||
%> | ||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> | ||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> | ||
<html> | ||
<head> | ||
<base href="<%=basePath%>"> | ||
|
||
<title>展现界面</title> | ||
|
||
|
||
|
||
</head> | ||
|
||
<body> | ||
<c:out value="${res}" /> | ||
</body> | ||
</html> |