HTML from 表单提交请求到servlet 实例

HTML源码展示:

<!DOCTYPE html>
<html>
<head>
<style type="text/css">
div#container{width:100%;}

div#menu {background-color:#e2e6ee;height:500px;width:50%;float:left;text-align:center; background-image:margin:0; color:#333333;}
div#content {background-color:#EEEEEE;height:500px;width:50%;float:left;width:expression(window.screen.height);}
body{background:#1d3647;}
#from{ margin-top:20%;margin-left:10%;}
#logo{margin-top:20%; float:right; margin-right:10%; }
#adv{margin-top:27%; float:right; margin-right:1%; font:"宋体"; color:#777; font-size:14px;}
</style>
</head>

<body>
<br/>
<br/>


<div id="container">



<div id="menu">
<img src="platefrom/images/LOGO01.gif"id="logo"/><br/>
<div id="adv">
<strong>  1- 地区商家信息网门户站建立的首选方案...</strong><br/><br/>
<strong>2- 一站通式的整合方式,方便用户使用...</strong><br/><br/>
<strong>3- 强大的后台系统,管理内容易如反掌...</strong>
</div>

</div>

<div id="content">
<!--表单-->
 <form action="./LoginServlet" method="get" id="from">
 <strong style="font:'宋体'; color:#777; font-size:16px;">登入后台信息管理</strong><br/><br/>
用户名:        <input type="text" name="username"  /><br /><br/>
密  码:        <input type="password" name="password" /><br /> <br/><br/>   

<input type="submit"  value="登    陆" style="font:'宋体'; font-size:16px;"/>      
<input type="submit"  value="取    消" style="font:'宋体'; font-size:16px;"/>
</form>
</div>


</div>

</body>
</html>

后台Servlet
package com.platefrom.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class LoginServlet extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Override
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		//默认用户名和密码:admin和123456
		String username=request.getParameter("username");
		String password=request.getParameter("password");
		//逻辑判断操作
		if(username.equals("admin")&&password.equals("123456")){
			//功能界面
			response.sendRedirect("./platefrom/main.html");
		}else{
			//登入页面
			response.sendRedirect("./platefrom/login.html");
		}
		
	}

	@Override
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		this.doGet(request, response);
	}
	
	

}



评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值