我需要你的帮助!我有一个项目,我遇到了希腊字符的问题。它告诉我??????当我传递一个参数。 这是我的代码:
<%@ page contentType="text/html; charset=utf-8" %>
<%@ page import="java.sql.*"%>
<%@ page import="myimpact_package.DonatorDAO" %>
<%@ page import="java.util.*"%>
<%@ page import="java.io.*,javax.servlet.*,javax.servlet.http.*,java.lang.*"%>
<%
request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");
response.getCharacterEncoding();
response.setContentType("text/html; charset=UTF-8");
%>
<%-- Take organization's name --%>
<%
String info="";
if ((request.getParameter("info")!=null)){
info=request.getParameter("info");
info= new String(info.getBytes("ISO-8859-1"), "UTF-8");
}
%>
<%-- First choice : Login.jsp calls ConfirmationController --%>
<% String code=request.getParameter("code");
int id=Integer.parseInt(code);
if (id==1) {
String username =request.getParameter("username");
String password =request.getParameter("password");
DonatorDAO dondao = new DonatorDAO();
dondao.open();
if ((dondao.isUserValid(username,password))==true) {
session.setAttribute("login","0d1b450a-e7ff-422c-9fc8-77195ae57a9f");
request.setAttribute("username",username);
request.setAttribute("password",password);
session.setAttribute("username",username);
session.setAttribute("password",password);
dondao.close();
%>
<%
if((session.getAttribute("checkpaymentform")!=null)&&(request.getParameter("info")!=null)){
session.removeAttribute("checkpaymentform");
RequestDispatcher rd = request.getRequestDispatcher("paymentform.jsp?username="+username+"&password="+password+"&info="+info);
rd.forward(request, response);
}else if((session.getAttribute("checksocialoffer")!=null)&&(request.getParameter("info")!=null)){
session.removeAttribute("checksocialoffer");
RequestDispatcher rd = request.getRequestDispatcher("socialoffer.jsp?username="+username+"&password="+password+"&info="+info);
rd.forward(request, response);
}
%>
这是socialoffer.jsp代码:
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ page import="java.util.*,java.lang.*,javax.servlet.RequestDispatcher"%>
<%@ page import="java.io.*,javax.servlet.*,javax.servlet.http.*"%>
<% request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");
response.getCharacterEncoding();
response.setContentType("text/html; charset=UTF-8");
%>
<%-- Take organization's name --%>
<% String info="";
if ((request.getParameter("info")!=null)){
info=request.getParameter("info");
info= new String(info.getBytes("ISO-8859-1"), "UTF-8");
}
%>
<% boolean name=false;
boolean lastname=false;
boolean offertype=false;
boolean deliverychoice=false;
boolean success_message=false;
name=Boolean.parseBoolean(request.getParameter("name_access"));
lastname=Boolean.parseBoolean(request.getParameter("lastname_access"));
offertype=Boolean.parseBoolean(request.getParameter("offer_type_message"));
deliverychoice=Boolean.parseBoolean(request.getParameter("donation_delivery_message")); success_message=Boolean.parseBoolean(request.getParameter("success_message"));
%>
<%-- Don't print error or success message when SocialOfferForm is called for the first time --%>
<%
if ( (request.getParameter("name_access")==null) || (request.getParameter("lastname_access")==null) || (request.getParameter("offer_type_message")==null) || (request.getParameter("donation_delivery_message")==null)){
name=true;
lastname=true;
offertype=true;
deliverychoice=true;
success_message=false;
} else {
if (request.getParameter("name_access")!=null) {
name=Boolean.parseBoolean(request.getParameter("name_access"));
}
if (request.getParameter("lastname_access")!=null) {
lastname=Boolean.parseBoolean(request.getParameter("lastname_access"));
}
if (request.getParameter("offer_type_message")!=null) {
offertype=Boolean.parseBoolean(request.getParameter("offer_type_message"));
}
if (request.getParameter("donation_delivery_message")!=null) {
deliverychoice=Boolean.parseBoolean(request.getParameter("donation_delivery_message"));
}
success_message=Boolean.parseBoolean(request.getParameter("success_message"));
info=request.getParameter("organization");
info= new String(info.getBytes("ISO-8859-1"), "UTF-8");
}
%>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>Myimp</title>
<link rel="stylesheet" href="css/style.css" type="text/css">
</head>
<body>
<div id="header">
<div>
<a href="index.jsp" class="logo"><img src="images/logo.png" alt=""> </a>
<ul>
<li>
<a href="index.jsp">x</a>
</li>
<li>
<a href="whydonate.jsp">u</a>
</li>
<li>
<a href="allorganizations.jsp">ol</a>
</li>
<li>
<a href="contact.jsp">y</a>
</li>
<%
if ((session.getAttribute("username")!=null)&&(session.getAttribute("password")!=null)){
if((!session.getAttribute("username").equals("null"))&&(!session.getAttribute("password").equals("null"))){
%>
<li class="has-sub">
<a href="profile.jsp">kol:<%=session.getAttribute("username")%></a>
<ul>
<li><a href="logout.jsp"><span>ki</span></a></li>
</ul>
</li>
<%
}else{
%>
<li>
<a href="login.jsp">ji</a>
</li>
<%
}}else{
%>
<li>
<a href="login.jsp">ki</a>
</li>
<%
}
%>
</ul>
</div>
</div>
<div id="body">
<div class="content">
<div class="head">
<h1>Myimp</h1>
</div>
<br> </br>
<form action="DonationController.jsp?info=<%=info%>&code=1" method="post" class="socialoffer">
<div class="form-group">
<label for="name">ΞΞ½ΞΏΞΌΞ±:<span class="asterisc">*</span></label>
<br></br>
<input size="112" height="250px" type="text" required="required" class="form-control" id="name" name="name" placeholder="Εισάγετε το ΟΞ½ΞΏΞΌΞ¬ σας">
<br></br>
</div>
<%-- Wrong name message --%>
<% if (!name) {
%>
<p style="color:#CC0000">ΣυμπληΟΟστε το πεδίο ΞΌΞµ το ΟΞ½ΞΏΞΌΞ¬ σας.</p>
<br></br>
<%
}
%>
<div class="form-group">
<label for="surname">ΕπΟΞ½Ο…ΞΌΞΏ:<span class="asterisc">*</span></label>
<br></br>
<input size="112" height="250px" type="text" required="required" class="form-control" id="surname" name="surname" placeholder="Εισάγετε το ΞµΟ€Ξ―ΞΈΞµΟ„Ο ΟƒΞ±Ο‚">
<br></br>
</div>
<%-- Wrong lastname message --%>
<% if (!lastname) {
%>
<p style="color:#CC0000">ΣυμπληΟΟστε το πεδίο ΞΌΞµ το ΞµΟ€ΟΞ½Ο…ΞΌΟ ΟƒΞ±Ο‚.</p>
<br></br>
<%
}
%>
<div class="form-group">
<label for="age">Ηλικία:<span class="asterisc">* </span></label>
<br></br>
<input size="112" height="250px" type="text" pattern="\d\d" title="##" required="required" class="form-control" id="age" name="age" placeholder="Εισάγετε την ηλικία σας">
<br></br>
</div>
<div class="form-group">
<label for="city">Ξ Ολη:<span class="asterisc">*</span> </label>
<br></br>
<input size="112" height="250px" type="text" required="required" class="form-control" id="city" name="city" placeholder="Εισάγετε την Ο€Ολη κατοικίας σας">
<br></br>
</div>
<div class="form-group">
<label for="address">ΔιεΟθυνση:<span class="asterisc">*</span></label>
<br></br>
<input size="112" height="250px" type="text" required="required" class="form-control" id="address" name="address" placeholder="Εισάγετε την διεΟθυνση κατοικίας σας">
<br></br>
</div>
<div class="form-group">
<label for="telephone">ΞΞΉΞ½Ξ·Ο„Ο Ξ¤Ξ·Ξ»Ξφωνο:<span class="asterisc">*</span></label>
<br></br>
<input size="112" height="250px" type="text" pattern="\d\d\d\d\d\d\d\d\d\d" title="##########" required="required" class="form-control" id="telephone" name="telephone" placeholder="Εισάγετε τον Ξ±ΟΞΉΞΈΞΌΟ Ο„ΞΏΟ… τηλεφΟΞ½ΞΏΟ… σας">
<br></br>
</div>
<div class="form-group">
<label for="email">Email:<span class="asterisc">*</span></label>
<br></br>
<input size="112" height="250px" type="email" required="required" class="form-control" id="email" name="email" placeholder="Εισάγετε το email σας">
<br></br>
</div>
<p>ΞΞσω αυτής της Ο†ΟΟΞΌΞ±Ο‚ σας δίνετε Ξ· δυνατΟτητα Ξ½Ξ± Ο€ΟοσφΞΟετε ΟΞΏΟχα, Ο„ΟΟφιμα ΞΊΞ±ΞΉ φάΟΞΌΞ±ΞΊΞ± σε Ξ±Ξ½ΞΈΟΟπους, αλλά ΞΊΞ±ΞΉ σε ΞΏΞΉΞΊΞΏΞ³ΞΞ½ΞµΞΉΞµΟ‚ που Ξχουν ανάγκη Ξ³ΞΉΞ± τη βοήθειά σας.</p>
<div class="form-group">
<label for="choose">ΕπιλΞξτε την κατηγοΟΞ―Ξ± της Ο€ΟοσφοΟΞ¬ σας:<span class="asterisc">*</span></label>
<br> </br>
<input type="radio" name="radio1" value="ΡοΟχα">ΡοΟχα</input>
<br> </br>
<input type="radio" name="radio1" value="Ξ¤ΟΟφιμα">Ξ¤ΟΟφιμα</input>
<br> </br>
<input type="radio" name="radio1" value="ΦάΟΞΌΞ±ΞΊΞ±">ΦάΟΞΌΞ±ΞΊΞ±</input>
<br> </br>
</div>
<%-- Wrong offertype message --%>
<% if (!offertype) {
%>
<p style="color:#CC0000">ΕπιλΞξτε το είδος της Ο€ΟοσφοΟάς που επιθυμείτε.</p>
<%
}
%>
<div class="form-group">
<br> </br>
<label for="elaborate">Ξ ΞµΟΞΉΞ³ΟΞ¬Οτε τι Ξ±ΞΊΟΞΉΞ²ΟΟ‚ ΞΈΞ± πεΟιλαμβάνει Ξ· Ο€ΟοσφοΟΞ¬ σας(Ο€.Ο‡ πεΟΞΉΞ³ΟΞ¬Οτε Ο€Οση ποσΟτητα ΞΈΞ± Ο€ΟοσφΞΟετε):<span class="asterisc">*</span></label>
<br> </br>
<textarea name="mytext" required="required" cols="30" rows="5"></textarea>
<br> </br>
</div>
<div class="form-group">
<br> </br>
<label>Ξ ΟΟ‚ ΞΈΞ± επιθυμοΟσατε Ξ½Ξ± Ξ΄Οσετε την Ο€ΟοσφοΟΞ¬ σας:<span class="asterisc">*</span></label>
<br> </br>
<input type="radio" name="radio2" value="Ξ•Ο€ΞΉΞΈΟ…ΞΌΟ Ξ½Ξ± στείλω τη Ο€ΟοσφοΟΞ¬ ΞΌΞΏΟ… ταχυδΟΞΏΞΌΞΉΞΊΟΟ‚">Ξ•Ο€ΞΉΞΈΟ…ΞΌΟ Ξ½Ξ± στείλω τη Ο€ΟοσφοΟΞ¬ ΞΌΞΏΟ… ταχυδΟΞΏΞΌΞΉΞΊΟΟ‚
<br> </br>
<input type="radio" name="radio2" value="Ξ•Ο€ΞΉΞΈΟ…ΞΌΟ Ξ½Ξ± ΞµΟ€ΞΉΟƒΞΊΞµΟ†Ο„Ο Ξ±Ο…Ο„ΞΏΟ€ΟΞΏΟƒΟπως τον ΞΏΟΞ³Ξ±Ξ½ΞΉΟƒΞΌΟ Ξ³ΞΉΞ± Ξ½Ξ± παΟΞ±Ξ΄Οσω τη Ο€ΟοσφοΟΞ¬ ΞΌΞΏΟ…">Ξ•Ο€ΞΉΞΈΟ…ΞΌΟ Ξ½Ξ± ΞµΟ€ΞΉΟƒΞΊΞµΟ†Ο„Ο Ξ±Ο…Ο„ΞΏΟ€ΟΞΏΟƒΟπως τον ΞΏΟΞ³Ξ±Ξ½ΞΉΟƒΞΌΟ Ξ³ΞΉΞ± Ξ½Ξ± παΟΞ±Ξ΄Οσω τη Ο€ΟοσφοΟΞ¬ ΞΌΞΏΟ…
<br> </br>
<input type="radio" name="radio2" value="ΞΞ± επιθυμοΟσα Ξ½Ξ± επικοινωνήσει κάποιος μαζί ΞΌΞΏΟ… Ξ³ΞΉΞ± Ξ½Ξ± συζητήσουμε τον Ο„ΟΟπο αποστολής της Ο€ΟοσφοΟάς ΞΌΞΏΟ…">ΞΞ± επιθυμοΟσα Ξ½Ξ± επικοινωνήσει κάποιος μαζί ΞΌΞΏΟ… Ξ³ΞΉΞ± Ξ½Ξ± συζητήσουμε τον Ο„ΟΟπο αποστολής της Ο€ΟοσφοΟάς ΞΌΞΏΟ…
<br> </br>
<%-- Wrong deliverychoice message --%>
<% if (!deliverychoice) {
%>
<p style="color:#CC0000">ΕπιλΞξτε τον Ο„ΟΟπο παΟάδοσης της Ο€ΟοσφοΟάς σας.</p>
<%
}
%>
<div class="col-sm-100">
<br> </br>
<button type="submit" class="btn btn-primary">Υποβολή</button>
<button type="reset" class="btn btn-primary">AΞΊΟΟωση</button>
</div>
</div>
<%--Success message --%>
<% if (success_message) { %>
<br> </br>
<p style="color:#009900">Ξ— Ο€ΟοσφοΟΞ¬ σας καταχωΟήθηκε επιτυχΟΟ‚.</p>
<% } %>
</form>
</div>
</div>
</body>
这是DonationController.jsp代码:
<%@ page contentType="text/html; charset=utf-8" %>
<%@ page import="java.sql.*"%>
<%@ page import="myimpact_package.DonationDAO" %>
<%@ page import="java.util.*"%>
<%@ page import="java.io.*,javax.servlet.*,javax.servlet.http.*,java.lang.*"%>
<% request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");
response.getCharacterEncoding();
response.setContentType("text/html; charset=UTF-8");
%>
<%
String code=request.getParameter("code");
int id=Integer.parseInt(code);
%>
<%-- First choice_access : SocialOffer.jsp calls DonationController --%>
<%
if (id==1) {
String organization="";
if ((request.getParameter("info")!=null)){
organization=request.getParameter("info");
organization= new String(organization.getBytes("ISO-8859-1"), "UTF-8");
}
String firstname=request.getParameter("name");
String lastname=request.getParameter("surname");
String age=request.getParameter("age");
String city=request.getParameter("city");
String address=request.getParameter("address");
String telephone_number=request.getParameter("telephone");
String email_address=request.getParameter("email");
String kindoffer=request.getParameter("radio1");
String donation_details=request.getParameter("mytext");
String donation_delivery_choice_access1=request.getParameter("radio2");
String offer_type="";
String donation_delivery_choice_access="";
String name_access="true";
String lastname_access="true";
String offer_type_message="true";
String donation_delivery_message="true";
DonationDAO donation = new DonationDAO();
donation.open();
boolean a=donation.check_name(firstname);
boolean b=donation.check_lastname(lastname);
donation.close();
if (kindoffer!=null) {
offer_type=request.getParameter("radio1");
}
if (donation_delivery_choice_access1!=null) {
donation_delivery_choice_access=request.getParameter("radio2");
}
if ((offer_type==null) || (offer_type.equals("")) || (donation_delivery_choice_access==null) || (donation_delivery_choice_access.equals("")) || (a==false) || (b==false)) {
if ((offer_type==null) || (offer_type.equals(""))) {
offer_type_message="false";
}
if ((donation_delivery_choice_access==null) || (donation_delivery_choice_access.equals(""))){
donation_delivery_message="false";
}
if (a==false) {
name_access="false";
}
if (b==false) {
lastname_access="false";
}
if ((organization!=null)){
organization=request.getParameter("info");
organization= new String(organization.getBytes("ISO-8859-1"), "UTF-8");
}
response.sendRedirect("socialoffer.jsp?organization="+organization+"&offer_type_message="+offer_type_message + "&donation_delivery_message=" + donation_delivery_message + "&name_access=" + name_access + "&lastname_access=" + lastname_access);
}
else if ((offer_type!=null) || (donation_delivery_choice_access!=null) || (a==true) || (b==true)) {
if (offer_type!=null) {
offer_type_message="true";
}
if (donation_delivery_choice_access!=null) {
donation_delivery_message="true";
}
if (a==true) {
name_access="true";
}
if (b==true) {
lastname_access="true";
}
if ((organization!=null)){
organization=request.getParameter("info");
organization= new String(organization.getBytes("ISO-8859-1"), "UTF-8");
}
String success_message="true";
DonationDAO donation2 = new DonationDAO();
donation2.open();
donation2.sendDonation(firstname,lastname,age,city,address,telephone_number,email_address,organization,offer_type,donation_details,donation_delivery_choice_access);
donation2.close();
response.sendRedirect("socialoffer.jsp?organization="+organization+"&offer_type_message="+offer_type_message + "&donation_delivery_message=" + donation_delivery_message + "&name_access=" + name_access + "&lastname_access=" + lastname_access + "&success_message=" + success_message);
}
}
%>
问题是:当来自ConfirmationController.jsp时,info参数将RequestDispatche传递给socialoffer.jsp,然后info参数以“action form”传递给DonationController.jsp,然后返回到socialoffer with sendRedirect,在url中我有此输出:socialoffer.jsp?organization = ?????&amp; offer_type_message = true&amp; donation_delivery_message = true&amp; name_access = true&amp; lastname_access = true&amp; success_message = true 我试过UTF而没有BOM,但没有!