• 图片验证码切换


    <%@ page language="java" contentType="text/html; charset=UTF-8"
        pageEncoding="UTF-8"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <!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=UTF-8">
    <title>Insert title here</title>
    <link href="<c:url value='/css/style.css'/>" rel="stylesheet" type="text/css"/>
    <script type="text/javascript">
    //地址获取
        function getRootPath(){
            var rootPath=window.location.pathname; //   /Day517/Ajax.jsp
            var index = rootPath.indexOf("/",1);
            rootPath = rootPath.substring(0,index);
            return rootPath;  //   /Day517
        }
    </script>
    </head>
    <body>
    <!-- 必须使用post提交 -->
    <span class="red">${msg }</span>
    <form action="<c:url value='/login.do'/>" method="post">
        <input type="text" name="username"/> <br/>
        <input type="text" name="password"/> <br/>
        <input type="text" name="verifycode"/> <br/>
        <img alt="看不清,换一张" src="<c:url value='/verifycode.do'/>" id="imgcheck" onclick="this.src=getRootPath()+'/verifycode.do?'+Math.random()"/><br/>
        <input type="submit" value="ok"/> <br/>
    </form>
    </body>
    </html>
    @Controller
    public class VerifyCodeController {
        @RequestMapping("/verifycode.do")
        public void doverifycode(HttpServletRequest request,HttpServletResponse response) throws IOException {
            VerifyCode vc  =new VerifyCode();
            BufferedImage image = vc.getImage();
            String text = vc.getText();
            request.getSession().setAttribute("session_verifycode", text);
            VerifyCode.output(image, response.getOutputStream());
        }
    }    
  • 相关阅读:
    Android 使用 DownloadManager 管理系统下载任务的方法
    移动互联网时代:你的厕所文学是什么?
    zoj 3777 Problem Arrangement(壮压+背包)
    25个增强iOS应用程序性能的提示和技巧(0基础篇)
    Oracle 同义词
    Oracle loop、while、for循环
    Oracle 序列
    Oracle 视图
    Oracle 集合操作
    Oracle 伪列
  • 原文地址:https://www.cnblogs.com/19322li/p/11116312.html
Copyright © 2020-2023  润新知