我有4个页面需要收集多个字段并存储在我的数据库中。如何从每个页面(客户端/事务/常规设置和环境)获取所有数据并将其发送到" FetchEnvironmentData"类?
<div class="container">
<div class="row">
<div class="col-md-6">
<div class="row">
<div class="form-group">
<label for="name">Name:</label>
<input type="text" class="form-control" id="name">
</div>
</div>
<div class="row">
<h6>Deploy Apps:</h6>
<div class="well">
<div class="checkbox">
<label><input type="checkbox" value="">Profile7</label>
</div>
<div class="checkbox">
<label><input type="checkbox" value="">WebCSR</label>
</div>
<div class="checkbox">
<label><input type="checkbox" value="">WebAdmin</label>
</div>
<div class="checkbox">
<label><input type="checkbox" value="">WebClient</label>
</div>
</div>
</div>
</div>
<div class="col-md-6">
<div class="row">
<h6>From System Date:</h6>
<div class="form-group">
<div class='input-group date' id='initialDate'>
<input type='text' class="form-control" />
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
</div>
<div class="row">
<h6>To System Date:</h6>
<div class="form-group">
<div class='input-group date' id='finalDate'>
<input type='text' class="form-control" />
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
</div>
<div class="row">
<h5>DAYENDS to run: 7</h5>
</div>
<div class="row">
<h6>Users:</h6>
<div class="well">
<div class="checkbox">
<label><input type="checkbox" value="">Profile7</label>
</div>
<div class="checkbox">
<label><input type="checkbox" value="">WebCSR</label>
</div>
<div class="checkbox">
<label><input type="checkbox" value="">WebAdmin</label>
</div>
<div class="checkbox">
<label><input type="checkbox" value="">WebClient</label>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<!--Pagination-->
<div class="text-center">
<nav>
<ul class="pagination text-center">
<li class="page-item"><a class="page-link" href="#">Previous</a></li>
<li class="page-item active"><a class="page-link" href="GeneralSetup.jsp">1</a></li>
<li class="page-item"><a class="page-link" href="Clients.jsp">2</a></li>
<li class="page-item"><a class="page-link" href="Accounts.jsp">3</a></li>
<li class="page-item"><a class="page-link" href="Transactions.jsp">4</a></li>
<li class="page-item"><a class="page-link" href="Clients.jsp">Next</a></li>
</ul>
</nav>
</div>
</div>
</div>
</body>
</html>
&#13;
我尝试仅使用目前的名称进行测试但没有成功
public class FetchEnvironmentData extends HttpServlet {
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) {
String name = request.getParameter("name");
System.out.println(name);
}
任何帮助?谢谢你
答案 0 :(得分:0)
HTML表单
<form action="your_page" method="post">
<input type="text" name="firstName">
<input type="submit">
</form>
Servlet代码
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String fname = request.getParameter("firstName");
out.println(fname);
}
system.out显示控制台输出