我在我的购买界面填写信息时 中间需要填写中文信息,但是当我在网页上显示我所购买的明细时,填写的中文变成了问号,而插入数据库的数据也有问号 用数字或字母是可以的

Starry_lin 2020-05-23 05:02:27
结课程序 ,望各位大神帮忙看看

相关代码:
buy.jsp
<%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
<%request.setCharacterEncoding("UTF-8"); %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<jsp:useBean id="reg" scope="request" class="buy.BUYRegister"/>
</head>

<body>
<form action ="buycheck.jsp" method = "post">
<div class="login1">
<span class="login1_1">          <br>          购买 </span>
</div>
</div>
<div class="login2">
<span class="login2_1">  书籍编号:</span>
<input type="text" name="bookid" value="<jsp:getProperty name="reg" property="bookid"/>">
<%=reg.geterror("errorbookid") %><br>
</div>
<div class="login3">
<span class="login3_1"> 数量</span>
<input type="text" name="booknumber" value="<jsp:getProperty name="reg" property="booknumber"/>">
<%=reg.geterror("errorbooknumber") %><br>
</div>
<div class="login4">
<span class="login4_1">电话:</span>
<input type="text" name="useriphone" value="<jsp:getProperty name="reg" property="useriphone"/>">
<%=reg.geterror("erroruseriphone") %><br>
</div>
<div class="login4">
<span class="login4_1">地址:</span>
<input type="text" name="address" value="<jsp:getProperty name="reg" property="address"/>">
<%=reg.geterror("erroraddress") %><br>
</div>
<div class="login4">
<span class="login4_1">用户id:</span>
<input type="text" name="userid" value="<jsp:getProperty name="reg" property="userid"/>">
<%=reg.geterror("erroruserid") %><br>
</div>
</div>
<div class="login5">
<span class="login5_1"> </span>
<input type="submit" value="购买"> <input type = "reset" value="清空">
</div>

</form>
</body>
</html>
<style>
<style>
*{ font-size:50px; font-family:"宋体"; color:black;margin:0 auto;}

body{ margin:0; background-color:#66ccff;}
input{ border:none;}

.login1 {
width:1500px;
height:310px;
overflow:hidden;
text-align:center;
line-height: 120px;
letter-spacing:10px;
margin-bottom:2px;
}

.login1_1 {
font-size:110px;
font-weight:bold;
color:#FFFFFF;
}
.login2 {
background:#66ccff;
width:px;
height:80px;
overflow:hidden;
text-align:center;
line-height: 50px;
margin-bottom:1px;
}

.login2_1 {
font-size:40px;
font-weight:bold;
color:#FFFFFF;
}
.login3 {
background:#66ccff;
width:px;
height:80px;
overflow:hidden;
text-align:center;
line-height: 50px;
margin-bottom:1px;
}

.login3_1 {
font-size:40px;
font-weight:bold;
color:#FFFFFF;
}
.login4 {
background:#66ccff;
width:px;
height:80px;
overflow:hidden;
text-align:center;
line-height: 50px;
margin-bottom:1px;
}

.login4_1 {
font-size:40px;
font-weight:bold;
color:#FFFFFF;
}
.login5 {
background:#66ccff;
width:px;
height:40px;
overflow:hidden;
text-align:center;
line-height: 50px;
margin-bottom:1px;
}

.login5_1 {
font-size:20px;
font-weight:bold;
color:#FFFFFF;
}
</style>

buycheck.jsp
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%request.setCharacterEncoding("UTF-8"); %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'Check.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<jsp:useBean id="reg" scope="request" class="buy.BUYRegister"/>
<jsp:useBean id="regi" scope="request" class="buy.BUYRegisterDB"/>
<jsp:setProperty name="reg" property="*"/>
</head>

<body>
<%
if(reg.invalidate()){

regi.register(reg);
%>

<jsp:forward page = "scuess.jsp"/>
<%
}else{
%>
<jsp:forward page = "buy.jsp"/>
<%} %>
This is my JSP page. <br>
</body>
</html>

scuess.jsp
<%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
<%request.setCharacterEncoding("UTF-8"); %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'Sucess.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<jsp:useBean id="reg" scope="request" class="buy.BUYRegister"/>

</head>

<body>
<div class="login1">
<span class="login1_1"> <br>订单明细如下:</span>
</div>
<div class="login2">
<span class="login2_1">  书籍id:</span>
<jsp:getProperty name="reg" property="bookid"/><br>
</div>
<div class="login2">
<span class="login2_1">  数量</span>
<jsp:getProperty name="reg" property="booknumber"/><br>
</div>
<div class="login2">
<span class="login2_1">  电话:</span>
<jsp:getProperty name="reg" property="useriphone"/><br>
</div>
<div class="login2">
<span class="login2_1">  地址:</span>
<jsp:getProperty name="reg" property="address"/><br>
</div>
<div class="login2">
<span class="login2_1">  用户id:</span>
<jsp:getProperty name="reg" property="userid"/><br>
</div>
<div class="login2">
<span class="login2_1">  <a href="http://localhost:8080/a/buy.jsp">如订单信息错误可点击重回购买界面</a></span><br>
<span class="login2_1">  <a href="http://localhost:8080/a/buy.jsp">如无误可点击重回主界面</a></span>
</div>
</body>
</html>
<style>
*{ font-size:50px; font-family:"宋体"; color:black;margin:0 auto;}
body{ margin:0; background-color:#66ccff;}
input{ border:none;}
.login1 {
width:1000px;
height:210px;
overflow:hidden;
text-align:center;
line-height: 120px;
letter-spacing:10px;
margin-bottom:2px;
}

.login1_1 {
font-size:100px;
font-weight:bold;
color:#FFFFFF;
}
.login2 {
background:#66ccff;
width:px;
height:100px;
overflow:hidden;
text-align:center;
line-height: 50px;
margin-bottom:1px;
}

.login2_1 {
font-size:20px;
font-weight:bold;
color:#FFFFFF;
}
</style>


...全文
127 1 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
爱吃鱼的ねこ 2020-05-23
  • 打赏
  • 举报
回复
你有些是gbk有些是utf8,你统一吧gbk改成utf8就好了

58,452

社区成员

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

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