Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#4提交实验代码 #436

Merged
merged 5 commits into from
Nov 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package edu.hzu.javaweb.labs.se1414080902107;

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;

/**
* Servlet implementation class Se1414080902107
*/
@WebServlet("/Se1414080902107")
public class Se1414080902107Servlet extends HttpServlet {
private static final long serialVersionUID = 1L;

/**
* @see HttpServlet#HttpServlet()
*/
public Se1414080902107Servlet() {
super();
// TODO Auto-generated constructor stub
}

/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub

response.setContentType("text/html;charset=UTF-8");

String name =new String(request.getParameter("name").getBytes("ISO8859-1"),"UTF-8");
String phone =new String(request.getParameter("phone").getBytes("ISO8859-1"),"UTF-8");
String position = new String(request.getParameter("position").getBytes("ISO8859-1"),"UTF-8");
String description = new String(request.getParameter("description").getBytes("ISO8859-1"),"UTF-8");

PrintWriter out = response.getWriter();

String docType = "<!DOCTYPE html> \n";
out.println(docType +
"<html>\n" +
"<head><meta charset=\"utf-8\"><title>确认报修信息</title></head>\n" +
"<body bgcolor=\"#f0f0f0\">\n" +
"<h1 align=\"center\">" + "报修单信息:" + "</h1>\n" +
"<ul>\n" +
" <li><b>姓名:</b>"
+ name + "\n" +
" <li><b>电话:</b>"
+ phone + "\n" +
" <li><b>地点:</b>"
+ position + "\n" +
" <li><b>详情:</b>"
+ description + "\n" +
"</ul>\n" +
"<div align=\"center\">"+
"<button type=\"submit\" >确认</button> "+
"<button type=\"submit\" >返回</button>"+
"</div>"+
"</body></html>");

}

/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}

}
64 changes: 64 additions & 0 deletions jweb/web/1414080902107/index.jsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.0/css/bootstrap.min.css">
<link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.0/css/bootstrap-theme.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>
<script src="index.js" type="text/javascript"></script>
<style type="text/css">
#preview, .img, img{width:200px;height:200px;}
#preview {border:1px solid #000;}
</style>

<title>报修表</title>
</head>
<body>
<h1 align="center">报修信息</h1>
<form role="form" id="target" class="form-horizontal" action="<%=request.getContextPath() %>/1414080902107" method="post">
<div class="form-group">
<label for="inputName" class="col-sm-4 control-label">报修人</label>
<div class="col-xs-5">
<input type="text" class="form-control" id="inputName" name="name" placeholder="输入姓名">
</div>
</div>
<div class="form-group">
<label for="inputPhoneNumber" class="col-sm-4 control-label">联系方式</label>
<div class="col-xs-5">
<input type="Tel" class="form-control" id="inputPhoneNumber" name="phone" placeholder="输入手机号码" pattern="\d{11}">
</div>
</div>
<div class="form-group">
<label for="inputPosition" class="col-sm-4 control-label">报修地点</label>
<div class="col-xs-5">
<input type="" class="form-control" id="inputName" name="position" placeholder="输入报修地点,如10#A101,1-101">
</div>
</div>
<div class="form-group">
<label for="inputDescription" class="col-sm-4 control-label">详细情况</label>
<div class="col-xs-5">
<textarea class="form-control" rows=5 id="inputDescription" name="description" placeholder="描述报修设备详情情况"></textarea>
</div>
</div>
<div class="form-group">
<label for="inputImage" class="col-sm-4 control-label">上传图片</label>
<div class="col-xs-5">
<div id="preview"></div>
<input type="file" onchange="preview(this)">
</div>
</div>
<div class="checkbox">
<label class="col-sm-4 control-label"></label>
<input type="checkbox">影响较大,尽快维修
</div>
<div>
<label class="col-sm-4 control-label"></label>
<button type="submit" class="btn btn-default">提交</button>
</div>
</form>
</body>
</html>

128 changes: 60 additions & 68 deletions labs/1414080902107/index.jsp
Original file line number Diff line number Diff line change
@@ -1,73 +1,65 @@
<%@ page language="java" import="java.util.*" contentType="text/html;charset=utf-8" 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">
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="utf-8"/>
<base href="<%=basePath%>">

<title>Login</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="校园 学生组织 ztree">
<meta http-equiv="description" content="About login">
<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>
</head>

<body>
<div class="container">
<form id="login" class="form-horizontal" role="form">
<div class="form-group">
<label for="firstname" class="col-sm-2 control-label">名字</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="firstname" placeholder="名字">
</div>
</div>
<div class="form-group">
<label for="lastname" class="col-sm-2 control-label">姓</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="lastname" placeholder="姓">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<div class="checkbox">
<label>
<input type="checkbox">请记住我
</label>
</div>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.0/css/bootstrap.min.css">
<link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.0/css/bootstrap-theme.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>
<script src="index.js" type="text/javascript"></script>

<style type="text/css">
#preview, .img, img{width:200px;height:200px;}
#preview {border:1px solid #000;}
</style>

<title>报修表</title>
</head>
<body>
<h1 align="center">报修信息</h1>
<form role="form" id="target" class="form-horizontal">
<div class="form-group">
<label for="inputName" class="col-sm-4 control-label">报修人</label>
<div class="col-xs-5">
<input type="text" class="form-control" id="inputName" placeholder="输入姓名">
</div>
</div>
<div class="form-group">
<label for="inputPhoneNumber" class="col-sm-4 control-label">联系方式</label>
<div class="col-xs-5">
<input type="Tel" class="form-control" id="inputPhoneNumber" placeholder="输入手机号码" pattern="\d{11}">
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-default">登录</button>
<div class="form-group">
<label for="inputPosition" class="col-sm-4 control-label">报修地点</label>
<div class="col-xs-5">
<input type="" class="form-control" id="inputName" placeholder="输入报修地点,如10#A101,1-101">
</div>
</div>
</div>
</form>
<div class="form-group">
<label for="inputDescription" class="col-sm-4 control-label">详细情况</label>
<div class="col-xs-5">
<textarea class="form-control" rows=5 id="inputDescription" placeholder="描述报修设备详情情况"></textarea>
</div>
</div>

<script type="text/javascript">
$( "#login" ).submit(function(event) {
$.ajax({
url: "/JavaWeb2/success.json",
type:"post",
dataType: "json",
success: function(data){
alert(data.msg);
},
error: function(){
alert("error!");
}

});
event.preventDefault();
});
</script>
</body>
<div class="form-group">
<label for="inputImage" class="col-sm-4 control-label">上传图片</label>
<div class="col-xs-5">
<div id="preview"></div>
<input type="file" onchange="preview(this)">
</div>
</div>
<div class="checkbox">
<label class="col-sm-4 control-label"></label>
<input type="checkbox">影响较大,尽快维修
</div>
<div>
<label class="col-sm-4 control-label"></label>
<button type="submit" class="btn btn-default">提交</button>
</div>
</form>
</body>
</html>