Servlet编程实例-servlet学习之旅(三)
2024-09-10 22:32:20
LoginServlet代码:
public class LoginServlet extends HttpServlet{
@Override
protected void service(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
String name = req.getParameter("uName");
String pswd = req.getParameter("uPswd");
System.out.println("用户名:"+name);
System.out.println("密码:"+pswd);
}
}
Login.jsp的代码:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>登陆界面</title>
</head>
<body>
<form action="<%= request.getContextPath() %>/loginServlet" method="get">
userName:<input type="text" name="uname" /><br/>
userPwsd:<input type="password" name="upwsd" /><br/>
<input type="submit" value="Login"/>
<input type="reset" value="Reset"/>
</form>
</body>
</html>
配置文件
<servlet>
<servlet-name>LoginServlet</servlet-name>
<servlet-class>liu.peng.servlet.LoginServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>LoginServlet</servlet-name>
<url-pattern>/loginServlet</url-pattern>
</servlet-mapping>
效果图:
最新文章
- 命令查询网站是否开启CDN加速
- IIS报错 试图加载格式不正确 的程序集解决办法
- 好的 iOS 代码习惯
- HDU4502吉哥系列故事——临时工计划
- IOS 接ShareSDK问题
- System.Data.DbType 与其它DbType的映射关系
- 关于quotename的用法
- Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace 解决方法
- Celery 源码解析五: 远程控制管理
- 前端面试题系列(1):doctype作用 标准模式与兼容模式
- deeplearning.ai 卷积神经网络 Week 2 深度卷积网络:实例研究 听课笔记
- 基于 HTML5 的 WebGL 和 VR 技术的 3D 机房数据中心可视化
- PHP 常用设计模式 (转载)
- SpringBoot2.0 最简单的 idea 快速创建项目
- python模块安装注意事项
- 【转载】Vue项目自动转换 px 为 rem,高保真还原设计图
- JS频率控制函数
- mysql下的将多个字段名的值复制到另一个字段名中(批量更新数据)字符串拼接cancat实战例子
- Html解析
- RESTful源码学习笔记之RPC和 RESTful 什么区别
热门文章
- [BZOJ]4197: [Noi2015]寿司晚宴
- [BZOJ]2017省队十连测推广赛1
- 【Codeforces Round #431 (Div. 1) D.Shake It!】
- mysql 及 posgresql之优劣势大比拼
- js删除数组中的元素delete和splice的区别
- day06 Request Response
- My Stuck in C++
- C++ 程序在运行时不显示dos界面
- vue通过id从列表页跳转到对应的详情页
- 解决问题redis问题:ERR Client sent AUTH, but no password is set