为什么我的JSP程序想数据库存入汉字时会出现乱码?怎么解决啊?
我把存入数据库的源JSP代码贴上来给大家看看,请大家帮我想办法啊!!巨分奉上!<%@pagelanguage="java"import="java.util.*"page...
我把存入数据库的源JSP代码贴上来给大家看看,请大家帮我想办法啊!!巨分奉上!
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%
request.setCharacterEncoding("gb2312");
response.setCharacterEncoding("gb2312");
%>
<jsp:useBean id="connDbBean" scope="page" class="db.db"/>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 ">
<title>招标公告更新</title>
</head>
<body>
<%
String gid=request.getParameter("gid");
String biaoti=request.getParameter("biaoti");
String starttime=request.getParameter("starttime");
String endtime=request.getParameter("endtime");
String stract=request.getParameter("stract");
String shuoming=request.getParameter("shuoming");
String status="开放";
session.setAttribute("gid",gid);
String sql="insert into zhaobiao(gid,biaoti,stract,status,shuoming,starttime,endtime) values('"+gid+"','"+biaoti+"','"+stract+"','"+status+"','"+shuoming+"','"+starttime+"','"+endtime+"')";
connDbBean.executeUpdate(sql);
out.print("<script>alert('添加成功!');location.href='chanpin_add.jsp';</script>");
%>
</body>
</html>
汉字存入数据库后在数据库中显示为一连串的问号乱码。。。 展开
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%
request.setCharacterEncoding("gb2312");
response.setCharacterEncoding("gb2312");
%>
<jsp:useBean id="connDbBean" scope="page" class="db.db"/>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 ">
<title>招标公告更新</title>
</head>
<body>
<%
String gid=request.getParameter("gid");
String biaoti=request.getParameter("biaoti");
String starttime=request.getParameter("starttime");
String endtime=request.getParameter("endtime");
String stract=request.getParameter("stract");
String shuoming=request.getParameter("shuoming");
String status="开放";
session.setAttribute("gid",gid);
String sql="insert into zhaobiao(gid,biaoti,stract,status,shuoming,starttime,endtime) values('"+gid+"','"+biaoti+"','"+stract+"','"+status+"','"+shuoming+"','"+starttime+"','"+endtime+"')";
connDbBean.executeUpdate(sql);
out.print("<script>alert('添加成功!');location.href='chanpin_add.jsp';</script>");
%>
</body>
</html>
汉字存入数据库后在数据库中显示为一连串的问号乱码。。。 展开
3个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询