사용자가 자신의 정보를 편집 할 수있는 일부 텍스트 상자가 있습니다.데이터베이스의 문자 인코딩 문제 - 터키어 문자 - Java
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<h:head>
<title>Facelet Title</title>
</h:head>
<h:body>
<h:form>
<h1>Kişisel Bilgileri Değiştir</h1>
<h:panelGrid columns="4" >
<h:outputText value="Kullanıcı Adı: "></h:outputText>
<h:inputText style=" background-color: #DCDAD1; " id="tUserName" readonly="true" value="#{user.customer.username}" />
<h:outputText style="color: red" value="*Kullanıcı adı değiştirilemez" ></h:outputText>
<h:outputText></h:outputText>
<h:outputText id="tPassword" value="Şifre: "></h:outputText>
<h:inputText id="passwordInputText" required="true"
requiredMessage="*Şifre bilgisi zorunludur"
value="#{user.customer.password}" />
<h:outputText></h:outputText><h:outputText></h:outputText>
<h:outputText id="tName" value="Ad: "></h:outputText>
<h:inputText id="nameInputText" required="true"
requiredMessage="*İsim bilgisi zorunludur"
value="#{user.customer.name}" />
<h:outputText></h:outputText>
<h:outputText></h:outputText>
<h:outputText id="tSurName" value="Soyad: "></h:outputText>
<h:inputText id="surnameInputText" required="true"
requiredMessage="*Soyad bilgisi zorunludur"
value="#{user.customer.surname}" />
<h:outputText></h:outputText><h:outputText></h:outputText>
<h:outputText id="tPhone" value="Telefon: "></h:outputText>
<h:inputText id="phoneInputText" required="true"
requiredMessage="*Telefon bilgisi zorunludur"
value="#{user.customer.phone}" />
<!-- validatorMessage="*Örnek:+902123475671">
<f:validateRegex pattern=
"\+[0-9]{12}" />
</h:inputText>-->
<h:outputText></h:outputText>
<h:outputText id="tAddress" value="Adres: "></h:outputText>
<h:inputTextarea rows="5" id="addressInputText" value="#{user.customer.address}" />
<h:outputText></h:outputText><h:outputText></h:outputText>
<h:outputText id="tEmail" value="E-mail: "></h:outputText>
<h:inputText id="emailInputText" required="true"
requiredMessage="*E-mail bilgisi zorunludur"
value="#{user.customer.email}"
validatorMessage="*E-mail formatı yanlış">
<f:validateRegex pattern=
"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" />
</h:inputText>
<h:outputText></h:outputText><h:outputText></h:outputText>
<h:commandButton value="Onayla" action="#{user.editInfo()}">
</h:commandButton>
</h:panelGrid>
</h:form>
</h:body>
</html>
내가 phpMyAdmin을하고 MySQL을 사용 : 여기에 해당 파일의 코드입니다. 여기 내 테이블 :
하지만 난이 텍스트 상자에 Ö, C, I, G, U, S와 같은 일부 문자를 입력하고 데이터베이스를 업데이트 할 때, 나는 그런 같은 이상한 문자를 얻을? Ä ° ± Å? Ã? çÃ? ¶. 이 문제를 어떻게 해결할 수 있습니까? 나는 utf8_bin 및 utf8turkish_ci를 데이터 정렬으로 시도했지만 작동하지 않습니다. 누구든지 도와 줄 수 있습니까?
감사
편집 : 저는 여기에 새로운 사용자 입력을 내 데이터베이스를 편집 어디는 : UTF-8 문자는 사용자 이름에 사용되는 설정 허용하면서
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package classes;
import java.io.Serializable;
import java.sql.Connection;
import java.sql.PreparedStatement;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
/**
*
* @author SUUSER
*/
@ManagedBean(name = "user")
@SessionScoped
public class User implements Serializable {
public static Customer customer;
private Connection con=null;
public void setCustomer(Customer customer) {
User.customer = customer;
}
public Customer getCustomer() {
return customer;
}
public User() {
}
public void editInfo() {
String name = customer.getName(), surname = customer.getSurname(), password = customer.getPassword();
String phone = customer.getPhone(), address = customer.getAddress(), email = customer.getEmail();
try {
con=DBConnect.connect();
int result = -1;
PreparedStatement checkDB = (PreparedStatement) con.prepareStatement(
"UPDATE users set password=?,name=?,surname=?,phone=?,address=?,"
+ "email=? where username=?");
checkDB.setString(7, customer.getUsername());
checkDB.setString(1, password);
checkDB.setString(2, name);
checkDB.setString(3, surname);
checkDB.setString(4, phone);
checkDB.setString(5, address);
checkDB.setString(6, email);
result = checkDB.executeUpdate();
con.close();
FacesContext.getCurrentInstance().getExternalContext().redirect("editsuccesfull.xhtml");
} catch (Exception e) {
e.printStackTrace();
}
}
}
또한'UTF-8' – BackSlash
당신은 자바 클래스 또는 관리 빈을 의미하는 사용자 데이터를 수신 페이지의 문자 인코딩을 설정해야? @BackSlash – yrazlik
제 말은 서버에서 사용자 데이터를 읽을 때 'UTF-8'을 사용하여 읽도록 지시해야한다는 것입니다. 새로운 데이터로 mysql 테이블을 업데이트하는 코드를 게시 할 수 있습니까? – BackSlash