数据提交页面代码:
<%@page contentType="text/html;charset=gb2312"%>
<%@page language="java" import="java.sql.*"%>
<jsp:useBean id="Info" class="app.background.DatabaseData" scope="request"/>
<jsp:useBean id="basefunc"    scope="page" class="app.zhengwu.basefunc" />
<%
String bszl_name = request.getParameter("bszl_name");
String content=request.getParameter("content");
String temp = new String(content.getBytes("ISO8859-1"),"GBK");
byte[] pic = temp.getBytes("GBK");
ByteArrayInputStream baisss = new ByteArrayInputStream(pic);
InputStreamReader bais = new InputStreamReader(baisss,"GBK");String sql="insert into baisjsgc_bszl(bszl_id,bszl_name,bszl_conts) values(bszl_id.nextval,'"+bszl_name+"','"+temp+"')";
Info.executeUpdate(sql);
Info.close();%>因为我是新手 不知道怎么写来获取
String content=request.getParameter("content");
String temp = new String(content.getBytes("ISO8859-1"),"GBK");
byte[] pic = temp.getBytes("GBK");
ByteArrayInputStream baisss = new ByteArrayInputStream(pic);
InputStreamReader bais = new InputStreamReader(baisss,"GBK");
这一串代码的值
如果用只获取"+temp+" 就会出现乱码 前台显示的文本都是 “????? ”我知道
pstmt.setCharacterStream(3,bais,pic.length);
可以获取
但是不知道用上面的方法怎么写~
请高人指点

解决方案 »

  1.   

    把它改成
    String temp = new String(content.getBytes("8859_1"));
    尝试一下
      

  2.   

    jsp页面保存到数据库有乱码解决方法Jsp+tomcat+bean中文乱码问题解决方法javabean中参数有乱码
    1) 所有的jsp页面指定字符编码方式,如:Charest=gb2312,Charest=UTF-8等等
    2) 在应用服务器中的server.xml方件中找到设置服务器端口的行,一般是这样开头:”<Connector port="8080"”,
    3) 在找到的行"<Connector"开头的字符串后加上:URIEncoding="UTF-8" ,保存文件
    --------------------------------------------------------------------------
    jsp页面有乱码解决方法    所有的jsp页面指定字符编码方式,如:Charest=gb2312,Charest=UTF-8等等
        <%@ page contentType="text/html; charset=UTF-8">
    --------------------------------------------------------------------------
    jsp单个中文参数乱码解决方法    用这个转换一下: 
        <%!String trans(String chi)
           {
            string result =null;
            byte temp[];
            temp=chi.getBytes("iso=8859-1");
            result= new String(temp);
            }
        %>
    或者直接这样:
        <% 
          request.setCharacterEncoding("UTF-8");
          out.println(request.getParameter("参数ID")
        %>
    --------------------------------------------------------------------------