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
hom yu
committed
Nov 15, 2016
1 parent
8696703
commit c9a5da4
Showing
4 changed files
with
231 additions
and
0 deletions.
There are no files selected for viewing
99 changes: 99 additions & 0 deletions
99
jweb/src/edu/hzu/javaweb/labs/se1414080902140/Student.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,99 @@ | ||
package edu.hzu.javaweb.labs.se1414080902140; | ||
|
||
public class Student { | ||
private String name, sex, | ||
sno, age, hight, weight, pulmonary, | ||
longRun, shortRun; | ||
|
||
public Student(String name, String sex, String sno, String age, | ||
String hight, String weight, String pulmonary, String longRun, | ||
String shortRun) { | ||
super(); | ||
this.name = name; | ||
this.sex = sex; | ||
this.sno = sno; | ||
this.age = age; | ||
this.hight = hight; | ||
this.weight = weight; | ||
this.pulmonary = pulmonary; | ||
this.longRun = longRun; | ||
this.shortRun = shortRun; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getSex() { | ||
return sex; | ||
} | ||
|
||
public void setSex(String sex) { | ||
this.sex = sex; | ||
} | ||
|
||
public String getSno() { | ||
return sno; | ||
} | ||
|
||
public void setSno(String sno) { | ||
this.sno = sno; | ||
} | ||
|
||
public String getAge() { | ||
return age; | ||
} | ||
|
||
public void setAge(String age) { | ||
this.age = age; | ||
} | ||
|
||
public String getHight() { | ||
return hight; | ||
} | ||
|
||
public void setHight(String hight) { | ||
this.hight = hight; | ||
} | ||
|
||
public String getWeight() { | ||
return weight; | ||
} | ||
|
||
public void setWeight(String weight) { | ||
this.weight = weight; | ||
} | ||
|
||
public String getPulmonary() { | ||
return pulmonary; | ||
} | ||
|
||
public void setPulmonary(String pulmonary) { | ||
this.pulmonary = pulmonary; | ||
} | ||
|
||
public String getLongRun() { | ||
return longRun; | ||
} | ||
|
||
public void setLongRun(String longRun) { | ||
this.longRun = longRun; | ||
} | ||
|
||
public String getShortRun() { | ||
return shortRun; | ||
} | ||
|
||
public void setShortRun(String shortRun) { | ||
this.shortRun = shortRun; | ||
} | ||
|
||
|
||
|
||
|
||
} | ||
|
48 changes: 48 additions & 0 deletions
48
jweb/src/edu/hzu/javaweb/labs/se1414080902140/SubmitServlet.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,48 @@ | ||
package edu.hzu.javaweb.labs.se1414080902140; | ||
|
||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import javax.servlet.Servlet; | ||
import javax.servlet.ServletConfig; | ||
import javax.servlet.ServletException; | ||
import javax.servlet.ServletRequest; | ||
import javax.servlet.ServletResponse; | ||
import javax.servlet.http.HttpServlet; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
|
||
public class SubmitServlet extends HttpServlet { | ||
private static final long serialVersionUID = 1L; | ||
public SubmitServlet() { | ||
// TODO Auto-generated constructor stub | ||
|
||
super(); | ||
} | ||
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { | ||
doPost(request, response); | ||
} | ||
|
||
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { | ||
request.setCharacterEncoding("UTF-8"); | ||
String name=request.getParameter("name"); | ||
String sno=request.getParameter("sno"); | ||
String sex=request.getParameter("sex"); | ||
String age=request.getParameter("age"); | ||
String hight=request.getParameter("hight"); | ||
String weight=request.getParameter("weight"); | ||
String pulmonary=request.getParameter("pulmonary"); | ||
String longRun=request.getParameter("longRun"); | ||
String shortRun=request.getParameter("shortRun"); | ||
//Student student=new Student("name"); | ||
List<Student> stuList=new ArrayList<Student>(); | ||
stuList.add(new Student(name,sex,sno,age,hight,weight,pulmonary,longRun,shortRun)); | ||
request.setAttribute("result", stuList); | ||
|
||
|
||
|
||
request.getRequestDispatcher("/doSubmit.jsp").forward(request, response); | ||
|
||
} | ||
} |
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,35 @@ | ||
<%@ page language="java" import="java.util.*,test.Student" pageEncoding="UTF-8"%> | ||
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> | ||
|
||
<% | ||
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>提交的数据</title> | ||
</head> | ||
<body> | ||
<c:if test="${username != null}"> | ||
<c:out value="${username}"/>您好 | ||
</c:if> | ||
<h2>您提交的内容如下:</h2> | ||
<% request.setCharacterEncoding("utf-8");%> | ||
<c:forEach var="student" items="${result}"> | ||
<ul> | ||
<li> 学号: ${student.sno}</li> | ||
<li> 姓名: ${student.name}</li> | ||
<li> 年龄:${student.age}</li> | ||
<li> 性别: ${student.sex}</li> | ||
<li> 身高: ${student.hight}</li> | ||
<li> 体重: ${student.weight}</li> | ||
<li> 长跑: ${student.longRun}</li> | ||
<li> 短跑 ${student.shortRun}</li> | ||
<li>肺活量: ${student.pulmonary} </li> | ||
</ul> | ||
</c:forEach> | ||
</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,49 @@ | ||
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> | ||
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> | ||
<% | ||
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> | ||
<style> | ||
div{ | ||
width:1300px; | ||
height:200px; | ||
position:absolute; | ||
left:50%; | ||
top:50%; | ||
margin:-100px 0 0 -150px | ||
} | ||
</style> | ||
|
||
<base href="<%=basePath%>"> | ||
<title>体侧信息提交页面</title> | ||
</head> | ||
<body> | ||
<c:if test="${username != null}"> | ||
<c:out value="${username}"/>您好 | ||
</c:if> | ||
<div> | ||
<h3>添加学生体侧信息</h3> | ||
|
||
<form action="SubmitServlet" method="post"> | ||
学号<input type="text" name="sno"><br> | ||
姓名<input type="text" name="name"><br> | ||
性别<input type="checkbox" name="sex" value="男">男 | ||
<input type="checkbox" name="sex" value="女">女<br> | ||
年龄<input type="text" name="age"><br> | ||
身高<input type="text" name="hight"><br> | ||
体重<input type="text" name="weight"><br> | ||
长跑<input type="text" name="longRun"><br> | ||
短跑<input type="text" name="shortRun"><br> | ||
肺活量<input type="text" name="pulmonary"><br> | ||
|
||
<input type="submit" value="提交"> <input type="reset" value="重置"> | ||
</form> | ||
</div> | ||
</body> | ||
</html> |