您的位置:首页 > Web前端 > HTML

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

2014-03-19 12:36 330 查看
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);	}		}

                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐