itcast-tools-1.4.2.jar下载

分类:JAVA相关 软件版本:v1.0 大小:28KB 更新日期:2024年11月26日
本站评级:★★★★☆ 语言:简体中文 授权版本:免费软件 运行环境:Windows 11,Windows 10,Windows 8,Windows 7

itcast-tools-1.4.2.jar


itcast-tools-1.4.2.jar是实现jsp servlet验证码等功能必不可少的一款jar工具包,如果缺失了itcast-tools-1.4.2.jar包许多重要的功能将报错,马上下载此jar吧。

itcast-tools-1.4.2.jar

使用实例

<servlet>

<servlet-name>VerifyCodeServlet</servlet-name>

<servlet-class>cn.itcast.vcode.servlet.VerifyCodeServlet</servlet-class>

</servlet>

<servlet-mapping>

<servlet-name>VerifyCodeServlet</servlet-name>

<url-pattern>/VerifyCodeServlet</url-pattern>

</servlet-mapping>

利用itcast-tool包实现jsp+servlet验证码

需要的包名:itcast-tools.jar

新建LoginServlet.Java

package cn.itcast.test.web.servlet;

import java.io.IOException;

import javax.servlet.ServletException;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

import cn.itcast.servlet.BaseServlet;

public class LoginServlet extends BaseServlet {

public String login(HttpServletRequest request, HttpServletResponse response)

throws ServletException, IOException {

/*

* 校验验证码

* 1. 获取表单中的验证码

* 2. 获取图片上的文字

*/

String verifyCode = request.getParameter("verifyCode");

// VerifyCodeServlet会把真正的验证码保存到session中

String vcode = (String) request.getSession().getAttribute("vCode");

System.out.println(verifyCode.equalsIgnoreCase(vcode));

return null;

}

}

新建form.jsp

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

<head>

<title>My JSP 'form.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">

-->

<script type="text/javascript">

function _hyz() {

/*

1. 获取<img>元素

2. 给它的src指向为/tools/VerifyCodeServlet

*/

var img = document.getElementById("imgVerifyCode");

// 需要给出一个参数,这个参数每次都不同,这样才能干掉浏览器缓存!

img.src = "/tools/VerifyCodeServlet?a=" + new Date().getTime();

}

</script>

</head>

<body>

<%--

1. 写表单,其中包含图片(验证码)

2. 让图片显示出来:

把<img>的src指向VerifyCodeServlet,你需要在web.xml中部署VerfiyCodeServlet

3. 换一张

--%>

<form action="/tools/LoginServlet" method="post">

<%-- 添加一个参数:method=login --%>

<input type="hidden" name="method" value="login">

用户名:<input type="text"  name="name"/><br/>

密 码:<input type="password" name="pwd"/><br/>

验证码:<input type="text" name="verifyCode"/><br/>

<img src="/tools/VerifyCodeServlet" id="imgVerifyCode"/>

<a href="javascript:_hyz()">换一张</a>

<br/>

<input type="submit" value="提交"/>

</form>

</body>

</html>

文件预览

itcasttools1.4.2.jar下载

版权声明:itcast-tools-1.4.2.jar所展示的资源内容均来自于第三方用户上传分享,您所下载的资源内容仅供个人学习交流使用,严禁用于商业用途,软件的著作权归原作者所有,如果有侵犯您的权利,请来信告知,我们将及时撤销。


软件下载信息清单:


驱动文件名称 发布日期 文件大小 下载文件名
itcast-tools-1.4.2.jar安装包 2024年11月26日 28KB ItcastTools142Jar.zip
下载地址:
相关推荐: 驱动大全 / 软件下载

软件评论

昵称*

手机*

网址

驱动总数
22526+
文章总数
3520+
评论条数
265+
运行天数
300+