前端界面实现(由于验证码是动态获取所以用jsp格式)
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <base href="/Mvcpro/"/> <meta charset="UTF-8"> <title>Insert title here</title> <script type="text/javascript" src="js/jquery.min.js"></script> </head> <body> <span>${msg}</span> <form action="emp/login" method="POST"> <fieldset> <legend>请登录!</legend> 用户名:<input type="text" name="username" placehodler="输入用户名"><br><br> 密 码: <input type="password" name="pwd" placehodler="输入密码"><br><br> <img alt="图片不存在" src="imgCode" height="40px"><a href="javascript:void"> 看不清,换一张!</a><br><br> 验证码:<input type="text" name="code"> <br><br> <input type="submit" value="提交"> <input type="reset" value="重置"> </fieldset> </form> <script type="text/javascript"> $(function(){ $("form a").click(function(){//为a标签绑定了一个单机事件 $("form img").attr("src","imgCode?ran="+new Date().getTime()); }) }) </script> </body> </html>