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); } }
相关文章推荐
- HTML通过from表单提交到servlet中文乱码问题
- action提交form表单,用于登录请求,servlet接收数据
- 【Extjs登陆】表单ajax提交,登录实例 后台为servlet
- Html表单提交到Servlet输出到页面乱码 Html使用的编码是UTF-8编码显示页面,之后使用form表单提交字段到Servlet中,Servlet将利用getParamer方法获得fo
- html提交表单到Servlet
- 使用表单post方式提交到某个servlet,请求参数不会在地址栏显示,达到隐藏请求参数的目的
- hhtml from表单为什么能提交数据
- Html表单提交到Servlet输出到页面乱码
- Servlet的5种方式实现表单提交(注册小功能),后台获取表单数据实例
- servlet获取表单提交的数据、请求转发、请求包含、请求重定向
- servlet请求中post提交表单重定向到跨域网站问题
- html 解决表单提交时调用jquery ajax出现执行了请求,但进入了error方法里面
- http模拟from表单提交,进行跨域请求和上传资源
- 微信小程序服务器请求和上传数据,上传图片并展示,提交表单完整实例代码附效果图
- Servlet的5种方式实现表单提交(注册小功能),后台获取表单数据实例
- 表单提交数据get请求和post请求的区别
- 表单提交数据大小的限制:Firebug 达到了 Post 请求大小限制
- 用Servlet处理表单提交的数据,然后再jsp页面中显示
- HTML中关于表单的提交
- ajax提交表单碰到页面刷新和发送两次请求的问题