如何在数据库中通过Spring Hibernate在TextBox中插入Gujarati?

我正在尝试使用Java Spring Hibernate Project将gujarati存储在postgreSQL数据库中但它存储的内容是这样的

મà«àª|à«àª¨àª¾àªàª¯-પરાàªàªàપાàªàª³àªàªààààààààààààààààààààààààààààààààààààààààààà«à

代替

મોદીનાજય-પરાજયપાછળઆવ્યક્તિનુંભેજું

在我的数据库编码是UTF-8,如果我直接在postgreSQL复制粘贴它正确存储但是从Web应用程序中的html表单它没有正确存储。

以下是我的hibernate.hbm.cfg文件

       org.postgresql.Driver   jdbc:postgresql://192.168.6.51:5432/JayHind?autoReconnect=true&useUnicode=true&createDatabaseIfNotExist=true&characterEncoding=utf-8  postgres pshiv  10   org.hibernate.dialect.PostgreSQLDialect   thread   org.hibernate.cache.NoCacheProvider   true  update utf8 utf8 true              

我也用过

%@ page language =“java”contentType =“text / html; charset = UTF-8”pageEncoding =“UTF-8”%>

在jsp页面中,这使古吉拉特语显示正确,但在表单提交中仍然存在问题。

在模型课上

 package com.models; import static javax.persistence.GenerationType.IDENTITY; import java.io.UnsupportedEncodingException; import java.util.Date; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.Table; import javax.persistence.UniqueConstraint; import javax.validation.Valid; import javax.validation.constraints.Pattern; import org.hibernate.validator.constraints.Email; import org.hibernate.validator.constraints.NotBlank; import org.springframework.format.annotation.DateTimeFormat; import com.sun.istack.internal.NotNull; @Entity @Table(name = "tbl_heading_info", uniqueConstraints = { @UniqueConstraint(columnNames = "id")}) public class Heading { private int id; @NotNull @NotBlank private String message; @Id @GeneratedValue(strategy = IDENTITY) @Column(name = "id", unique = true, nullable = false) public int getId() { return id; } public void setId(int id) { this.id = id; } @Column(name = "message", nullable = false) public String getMessage() { return message; } public void setMessage(String message) { this.message = message; /*byte ptext[] = null; try { ptext = message.getBytes("ISO_8859_1"); } catch (UnsupportedEncodingException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { String value = new String(ptext, "UTF-8"); this.message=value; } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } */ } } 

我也把filter放在web.xml中

  SetCharacterEncodingFilter org.springframework.web.filter.CharacterEncodingFilter  encoding UTF8   forceEncoding true    SetCharacterEncodingFilter *  

预期产出

预期的

电流输出

目前的行动

我不得不在上周面对这个,试试这个。 使用’definitivo’有textBox.getText()并转换为UTF-8

byte ptext [] = definitivo.getBytes(“ISO_8859_1”);

String value = new String(ptext,“UTF-8”);