jsp中框架页面请求中的中文编码问题

2008-02-23 09:16:29来源:互联网 阅读 ()

新老客户大回馈,云服务器低至5折

最近有这么一个需求,一个主页面从request中拿到请求的参数(中文),主页面里有两个Frame,

每个Frame嵌着一个JSP,如何把主页面中得到的中文参数值传入Frame里去呢,后来发现应该先把

中文编码成unicode,然后传给frame中的jsp,frame中的jsp再解码,程序清单如下:

index.jsp

====================================================================

<%@ page contentType="text/html; charset=UTF-8" %>
<%@ page import="Java.net.URLEncoder" %>
<%
String flowname = request.getParameter("flowname");
%>
<html>
<head>
<title>
业务相关资料
</title>
</head>

<frameset rows="70%,*" cols="*" framespacing="1" frameborder="yes" border="0">
<frame src="assetlist.jsp?flowname=<%=flowname%>" name="topFrame" frameborder="1" scrolling="auto" noresize>
<frame src="#" name="acceFrame" scrolling="auto">
</frameset>

</html>

assetlist.jsp

========================================================

<%@ page contentType="text/html; charset=utf-8" %>
<%@ taglib uri="/Web-INF/Struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ page import="com.founder.oa.common.Utils" %>
<%@ page import="com.founder.oa.uiFrame.complexSearch.*" %>
<%@ page import="gov.police.tech.wcminterface.*" %>
<%@ page import="gov.police.tech.application.dataExchange.*" %>
<%@ page import="com.founder.fdam.oaiInterface.*" %>
<%@ page import="com.founder.oa.DamInterfaceAdapter.*" %>
<%@ page import="java.util.*" %>
<%@ page import="gov.police.tech.application.appdata.*" %>
<%
String cond ="flowname = '" request.getParameter("flowname") "'";
// out.println(cond);

HttpSession sess = request.getSession();
int allpage = 0;//页数
String pageNo = request.getParameter("pageNo");
//pageNo为null,则赋值为1
if(pageNo==null){
pageNo="1";
sess.setAttribute("flowname",cond);
}
else{
cond = (String)sess.getAttribute("flowname");
// out.println(cond);
}
int p = Integer.parseInt(pageNo);//当前页

ArrayList al = new ArrayList();
int size=0;


try{

DAMInterfaceApp dapp = new DAMInterfaceApp();
Verify ver = new Verify(dapp);
ver.login("admin","admin");

QueryAssetExt quExt = QueryAssetExt.getInstance(dapp);

String strQueryResult = "";
try
{
strQueryResult = quExt.queryAllAssets(150,cond, "", "", 0);
}
catch(Exception qe)
{
System.err.print("错误:调用博思查询接口QueryAssetExt.queryAllAssets出错,错误信息为:" qe.getMessage());
}
//对得到的查询结果进行解析

//System.out.println("提示:查询结果为: " strQueryResult);
al = (ArrayList)QueryAssetAdapter.getQueryAssets(strQueryResult);
allpage = PageUtil.getAllpage(al);
//out.println(allpage);
al = PageUtil.getPageItems(al,p);
size = al.size();
//out.println(size);


}
catch(Exception e){
e.printStackTrace();
}

%>
<html>
<head>
<title>
业务相关资料
</title>
<link href="<%=request.getContextPath()%>/css/csstop.css" rel="stylesheet" type="text/css">
<link href="<%=request.getContextPath()%>/css/link_sty.css" rel="stylesheet" type="text/css">
<SCRIPT LANGUAGE="JavaScript" >
var swd = null;

function selected(t)
{
if(swd!=null)
swd.className = "";
if(t==swd)
{
swd = null;
return;
}
t.className = "xz";
swd=t;
submit();
}
function submit()
{
document.frmAssets.assetid.value = swd.id;
document.frmAssets.submit();

}

</SCRIPT>
<style>
#Table1 tr{ cursor:hand; }
.xz { color: #FFFFFF; background-color: #66CCCC; }
</style>

</head>
<body bgcolor="#ffffff">
<center>业务相关资料

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:什么时候应该使用Web Service

下一篇:用jdk自带包操作XML