两个简单的测试页面,第一个页面testpro.jsp代码
<%@ page language="java" contentType="text/html; charset=utf-8" import="java.sql.*,Configure.*,DB.*" pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%request.setCharacterEncoding("utf-8");
response.setCharacterEncoding("utf-8");
String str_4="刘若英-一切.mp3";
%>
<html>
<head>
<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">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script language="javascript">
function openScript(url,name,width,height)
{
var left = (screen.width-width)/2;
var top = (screen.height-height)/2;
var newWin = window.open(url,name, "left= " +left+ ",top= "+top+ ",width= "+width+ ",height= "+height);
newWin.focus();
return newWin;
}
</script>
</head>
<body>
<form id="form1" name="form1" method="post" action="media.jsp" >
<input type="text" size="50" align="middle" id="SearchCondition" name="searchcondition" value="" />
<input type="submit" height="100" size="60" name="Submit" style="font-size: 18px;" value="搜索" />
<a href="#" onclick="openScript('media.jsp?AudioPath=<%=str_4%>','pur',400,300)">下载</a>
</form>
</body>
</html>
点击下载之后会弹出来接收页面test.jsp
<%@ page contentType="text/html; charset=utf-8" language="java" import="java.util.*,Configure.*" pageEncoding="utf-8" %>
<%request.setCharacterEncoding("utf-8");
response.setCharacterEncoding("utf-8");
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
//String imagepath1=(String)session.getAttribute("audiopath");
String imagepath=request.getParameter("AudioPath");
out.println(imagepath);
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<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">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body bgcolor="white">
</body>
</html>
但是显示的结果为 刘若�?一�?mp3 一半为中文一半为乱码,该怎么解决,搞这乱码都两天了头都大了还没解决,大家可以测试一下,帮帮忙,重谢啊
<%@ page language="java" contentType="text/html; charset=utf-8" import="java.sql.*,Configure.*,DB.*" pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%request.setCharacterEncoding("utf-8");
response.setCharacterEncoding("utf-8");
String str_4="刘若英-一切.mp3";
%>
<html>
<head>
<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">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script language="javascript">
function openScript(url,name,width,height)
{
var left = (screen.width-width)/2;
var top = (screen.height-height)/2;
var newWin = window.open(url,name, "left= " +left+ ",top= "+top+ ",width= "+width+ ",height= "+height);
newWin.focus();
return newWin;
}
</script>
</head>
<body>
<form id="form1" name="form1" method="post" action="media.jsp" >
<input type="text" size="50" align="middle" id="SearchCondition" name="searchcondition" value="" />
<input type="submit" height="100" size="60" name="Submit" style="font-size: 18px;" value="搜索" />
<a href="#" onclick="openScript('media.jsp?AudioPath=<%=str_4%>','pur',400,300)">下载</a>
</form>
</body>
</html>
点击下载之后会弹出来接收页面test.jsp
<%@ page contentType="text/html; charset=utf-8" language="java" import="java.util.*,Configure.*" pageEncoding="utf-8" %>
<%request.setCharacterEncoding("utf-8");
response.setCharacterEncoding("utf-8");
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
//String imagepath1=(String)session.getAttribute("audiopath");
String imagepath=request.getParameter("AudioPath");
out.println(imagepath);
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<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">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body bgcolor="white">
</body>
</html>
但是显示的结果为 刘若�?一�?mp3 一半为中文一半为乱码,该怎么解决,搞这乱码都两天了头都大了还没解决,大家可以测试一下,帮帮忙,重谢啊
解决方案 »
- JAVA中 String数组怎么释放?
- hibernateTemplate 查询问题
- 为什么utf-8编码的JSP页面保存中文数据到MySQL后会变成乱码啊?
- sql server 连接问题!郁闷我一下午了!
- 服务器端如何才能拿到客户端的ip
- 请教一个js与Applet的问题
- Context ctx = new InitialContext(env)的ClassCastException异常问题!
- 100分求教:怎么能够得到html页面的实际显示值?
- 今天复试 前辈们帮忙看看!!!!!!!!!!!!!!!
- miniui控件
- 在线客服软件是怎么知道老客户来访的啊
- hibernate提示出错 求助
改成:
<a href="#" onclick="openScript('media.jsp?AudioPath='+encodeURIComponent('<%=str_4%>'),'pur',400,300)">下载 </a>