我想把"身份验证:请点击strawberry图片"英文水果名改成汉字...但是在项目中入把名称改掉,浏览器就会请求%7%6xxx.jsp结构上代码,注册页
<%@ 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>EasyCode Demo</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="EasyCode">
<meta http-equiv="description" content="EasyCode demo power by wangking, blog -> http://wangking717.javaeye.com">
<script type="text/javascript" src="js/jquery-1.4.2.js"></script>
</head>
<body>
<form action="verify.jsp">
<br/><br/><br/>
用户名:<input type="text" name="txtUsername" /><br/><br/><br/>
密码: <input type="text" name="txtPwd" /><br/><br/><br/>
<jsp:include page="mycode.jsp" flush="true"></jsp:include><br/><br/><br/>
<input type="submit" value="Submit" name="submit">
</form>
</body>
</html>"mycode.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<script type="text/javascript">
$(function(){
$("img[name='easy_code']").click(function(){
$("img[name='easy_code']").each(function(){
var img4each = $(this).attr("id");
$(this).attr("src","images/"+img4each+"_off.jpg");
});
var img = $(this).attr("id");
$(this).attr("src","images/"+img+"_on.jpg");
$("#randImg").attr("value",img);
});
});
</script>
<%
//包装图片集合,保存图片的名称
List<String> imgArray = new ArrayList<String>();
imgArray.add("apple");
imgArray.add("cherry");
imgArray.add("lemon");
imgArray.add("pear");
imgArray.add("strawberry");
int min = 0; //集合随机起点
int max = imgArray.size()-1; //集合随机终点
Random rdm = new Random();
int randNum = rdm.nextInt(max-min+1)+min; //随机出来的数组下标
String randImg = imgArray.get(randNum); //随机出来的图片名称
request.getSession().setAttribute("img",randImg);
out.print("身份验证:请点击"+randImg+"图片<br/><br/><br/>");
for(String img : imgArray){
out.print("<img src=\"images/"+ img +"_off.jpg\" id=\""+ img +"\" name=\"easy_code\"></img> ");
}
%>
<input type="hidden" name="randImg" id="randImg" value="">
<%@ 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>EasyCode Demo</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="EasyCode">
<meta http-equiv="description" content="EasyCode demo power by wangking, blog -> http://wangking717.javaeye.com">
<script type="text/javascript" src="js/jquery-1.4.2.js"></script>
</head>
<body>
<form action="verify.jsp">
<br/><br/><br/>
用户名:<input type="text" name="txtUsername" /><br/><br/><br/>
密码: <input type="text" name="txtPwd" /><br/><br/><br/>
<jsp:include page="mycode.jsp" flush="true"></jsp:include><br/><br/><br/>
<input type="submit" value="Submit" name="submit">
</form>
</body>
</html>"mycode.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<script type="text/javascript">
$(function(){
$("img[name='easy_code']").click(function(){
$("img[name='easy_code']").each(function(){
var img4each = $(this).attr("id");
$(this).attr("src","images/"+img4each+"_off.jpg");
});
var img = $(this).attr("id");
$(this).attr("src","images/"+img+"_on.jpg");
$("#randImg").attr("value",img);
});
});
</script>
<%
//包装图片集合,保存图片的名称
List<String> imgArray = new ArrayList<String>();
imgArray.add("apple");
imgArray.add("cherry");
imgArray.add("lemon");
imgArray.add("pear");
imgArray.add("strawberry");
int min = 0; //集合随机起点
int max = imgArray.size()-1; //集合随机终点
Random rdm = new Random();
int randNum = rdm.nextInt(max-min+1)+min; //随机出来的数组下标
String randImg = imgArray.get(randNum); //随机出来的图片名称
request.getSession().setAttribute("img",randImg);
out.print("身份验证:请点击"+randImg+"图片<br/><br/><br/>");
for(String img : imgArray){
out.print("<img src=\"images/"+ img +"_off.jpg\" id=\""+ img +"\" name=\"easy_code\"></img> ");
}
%>
<input type="hidden" name="randImg" id="randImg" value="">
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货