数据提交页面代码:
<%@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);
可以获取
但是不知道用上面的方法怎么写~
请高人指点
<%@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);
可以获取
但是不知道用上面的方法怎么写~
请高人指点
解决方案 »
- java.lang.ExceptionInInitializerError
- 在MyEclipse里面建Jsp文件以后,里面自带的这几句代码是什么意思?
- 关于jsp数据库没有显示
- Tomcat 4的错误,谁见过啊,这到底是什么问题呢?
- 一个高级程序员的学历问题请大家出出主意,说说看法
- 关于Web项目的第一个页面
- 关于一个jsp与javascript的传值问题??????????
- 一个简单的jsp竟然出错,请各位高手帮我看看是什么错误!
- 在访问数据库时候,嵌套WHILE(RS。NEXT()),为什么只循环一次就跳出了循环,WHY???
- 救救小弟,帮帮忙,关于网站规划
- JSP+oracle 9i中文乱码问题
- ajax的中文乱码问题
String temp = new String(content.getBytes("8859_1"));
尝试一下
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")
%>
--------------------------------------------------------------------------