jsp登录页面

来源:互联网 发布:rmvb转mp4 mac 编辑:程序博客网 时间:2024/06/01 17:02


<%@ page language="java" import="java.util.*" contentType = "text/html; charset=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"><html>  <head>    <base href="<%=basePath%>">        <title>My JSP 'index.jsp' starting page</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="keyword1,keyword2,keyword3"><meta http-equiv="description" content="This is my page"><!--<link rel="stylesheet" type="text/css" href="styles.css">-->  </head>  <body>   <h1>用户登录</h1>   <hr>   <form action = "chuli.jsp"  name = "loginForm"  method = "post">   <table>   <tr>   <td>用户名</td>   <td><input type="text" name = "username"></td>   </tr>   <tr>   <td>密码</td>   <td><input type = "text" name = "password"></td>   </tr>   <tr>   <td colspan = "2"><input type = "submit" value = "登陆"></td>   <!-- 这个colspan是指 表格单元横跨两列的表格 submit指的是表格中的提交按钮-->   </tr>   </table>      </form></body></html>


<%@ page language="java" import="java.util.*" contentType = "text/html; charset=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"><html>  <head>    <base href="<%=basePath%>">        <title>My JSP 'index.jsp' starting page</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="keyword1,keyword2,keyword3"><meta http-equiv="description" content="This is my page"><!--<link rel="stylesheet" type="text/css" href="styles.css">-->  </head>  <body>   <h1>处理页面</h1>   <%    request.setCharacterEncoding("utf-8") ;    //在接收数据之前更改编码 解决中文乱码问题     因为把数据放进tomcat中默认以ios编码输出   但是无法解决url传递进参数的乱码问题   要是想解决url传递进去的问题话 需要修改tomcat服务器   %>         <%    if(request.getParameter("username").equals("admin")  &&  request.getParameter("password").equals("admin"))   {   request.getReque/stDispatcher("login_success.jsp").forward(request,response);    //请求转发到login_success.jsp   }else   {   response.sendRedirect("login_failure.jsp");    //请求重定向   }   %></body></html>

//在处理页面转换格式为utf-8防止乱码
<%@ page language="java" import="java.util.*" 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"><html>  <head>    <base href="<%=basePath%>">        <title>My JSP 'index.jsp' starting page</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="keyword1,keyword2,keyword3"><meta http-equiv="description" content="This is my page"><!--<link rel="stylesheet" type="text/css" href="styles.css">-->  </head>    <body>    <h1>登录成功</h1>    用户:<%=request.getParameter("username") %><br>  </body></html>


<%@ page language="java" import="java.util.*" 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"><html>  <head>    <base href="<%=basePath%>">        <title>My JSP 'index.jsp' starting page</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="keyword1,keyword2,keyword3"><meta http-equiv="description" content="This is my page"><!--<link rel="stylesheet" type="text/css" href="styles.css">-->  </head>    <body>    <h1>登录失败</h1>  </body></html>