急急急!!关于乱码的页面传递

hzpike 2003-04-07 02:09:29
有一串字符串是经过加密函数后产生的乱码,现在要把该串传递到其他页面。

不管用form传递还是request传递,发现这窜乱码在jsp中破坏了程序本身的代码。
如:
<a href=javascript:tmp=window.open("<%=request.getContextPath()%>/jsp/manager/index.jsp?contextId=<%=encodestr%>","_blank","status=no,scrollbars=yes,top=20,left=110,width=630,height=200");tmp.focus();>登陆</a>

运行后发现window.open("函数丢失了后面的代码,javascript出错。

如何把乱码正常的传递到其他页面呢????




...全文
29 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
hzpike 2003-04-07
  • 打赏
  • 举报
回复
唉,都说了不是中文问题,是故意弄成乱码的,现在只要能把这个乱码正常的传递到另一页面就行了
duoshanx 2003-04-07
  • 打赏
  • 举报
回复
package com.wfsw;

import java.sql.*;
import java.lang.*;

public class dbcon {
Connection conn = null;
public Connection getConn(){

try {
Class.forName("oracle.jdbc.driver.OracleDriver");
conn = DriverManager.getConnection("jdbc:oracle:thin:@76.48.56.7:1521:test", "wfsw", "wfsw");
}
catch (Exception e) {
e.printStackTrace();
}
return conn;
}
}
/**********
定义一个对中文字符进行编码转换的方法
*/
public String ex_chinese(String str){
if(str==null||str.length()==0){
str ="" ;
}
else{
try {
str = new String(str.getBytes("iso-8859-1"),"GBK") ;
}
catch (Exception ex) {
}
}
return str ;
}

试试这个

<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<html>
<head>
<title>del fwjg</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<jsp:useBean id="beancon" scope="page" class="com.wfsw.dbcon" />
<body>
<%
/*
*String url = 上一页URL
*String db = 数据库名 <-必要参数
*String tjzd = 条件字段 <-必要参数
*String t = 条件字段值 <-必要参数
*String xgzd = 修改字段 <-必要参数
*String x = 修改字段值 <-必要参数
*String msg = 提示信息
*/
try {
String url = request.getHeader("Referer"); //上一页URL
String db = beancon.ex_chinese(request.getParameter("db")); //数据库名
String tjzd = beancon.ex_chinese(request.getParameter("tjzd")); //条件字段
String t = beancon.ex_chinese(request.getParameter("t")); //条件字段值
String xgzd = beancon.ex_chinese(request.getParameter("xgzd")); //修改字段
String x = beancon.ex_chinese(request.getParameter("x")); //修改字段值
Connection con = beancon.getConn();
Statement stmt = con.createStatement();
String sql="update "+db+" set "+xgzd+" = '"+x+"' where "+tjzd+"="+t;
stmt.executeUpdate(sql);
stmt.close();
con.close();
//判断是否显示msg
if (!(request.getParameter("msg")==null)){
String msg=beancon.ex_chinese(request.getParameter("msg"));
out.print("<script language='JavaScript' type='text/JavaScript'>alert (\""+msg+"\");self.location=\""+url+"\";</script>");
}else{
response.sendRedirect(url);
}
}
catch(java.sql.SQLException ex){
out.print(ex);
}
catch(Exception e){
out.println(e);
}
%>

</body>
</html>
hzpike 2003-04-07
  • 打赏
  • 举报
回复
没有人做过代码转换吗
hzpike 2003-04-07
  • 打赏
  • 举报
回复
我说的乱码不是中文问题造成的,是加密产生的,因为其中含有非法字符所以破坏了jsp或javascript代码。
JikLiu 2003-04-07
  • 打赏
  • 举报
回复
页面编码有没有设为:iso8859_1

81,090

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧