Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/350.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在mysql工作台中输入中文值但显示垃圾_Java - Fatal编程技术网

Java 在mysql工作台中输入中文值但显示垃圾

Java 在mysql工作台中输入中文值但显示垃圾,java,Java,} 这是我的java类,我通过jsp页面输入中文值,但它显示的是垃圾 数据库中的值,即mysql workbench。 我为中文数据读取xml文件,但jsp页面没有显示中文数据=?以进行调试 将XML文件加载到支持Unicode的XML编辑器(如记事本+)中 确保JSP文件显式声明其返回的Unicode。是JSP的起点 确保MySQL表使用Unicode 为此,请使用UTF8字符编码,以确保您使用的是数据库和表的正确获取元数据 对于表,请使用命令检查: private EntryContentT

}

这是我的java类,我通过jsp页面输入中文值,但它显示的是垃圾 数据库中的值,即mysql workbench。 我为中文数据读取xml文件,但jsp页面没有显示中文数据=?

以进行调试

  • 将XML文件加载到支持Unicode的XML编辑器(如记事本+)中
  • 确保JSP文件显式声明其返回的Unicode。是JSP的起点
  • 确保MySQL表使用Unicode

  • 为此,请使用UTF8字符编码,以确保您使用的是数据库和表的正确获取元数据

    对于表,请使用命令检查:

    private EntryContentTable entryContentTable ;
    private String ent_content_type;
    private String entry_con_val;
    private String entry_con_tag;
    private int ent_con_hide;
    
    public String execute(){
        String flag=INPUT;
    
        System.out.println("hello");
        try {
            session=ConnectionProvider.getSession();
            transaction=session.beginTransaction();
    
            entryContentTable=new EntryContentTable();
    
            entryContentTable.setEntry_cont_type(getEnt_content_type());
            entryContentTable.setEntry_cont_value(getEntry_con_val());
            entryContentTable.setEntry_cont_tag_name(getEntry_con_tag());
    
            session.save(entryContentTable);
            transaction.commit();
            flag = SUCCESS;
        } catch (Exception e) {
        System.out.println(e.toString());
        e.printStackTrace();
        }
        finally{
            return flag;
        }
    
    }
    public String entconupdate() {
         String flag=SUCCESS; 
        try{
            System.out.println("HIde Value mmmmmmmmm  ::: " +  ent_con_hide);
             session=ConnectionProvider.getSession();
             transaction=session.beginTransaction();
    
             entryContentTable=(EntryContentTable)session.load(EntryContentTable.class, ent_con_hide);
    
    
             entryContentTable.setEntry_cont_type(getEnt_content_type());
                entryContentTable.setEntry_cont_value(getEntry_con_val());
                entryContentTable.setEntry_cont_tag_name(getEntry_con_tag());
    
                session.update(entryContentTable);
    
                transaction.commit();
    
            return flag;
        }catch (Exception e) {
            e.printStackTrace();
            System.out.println("Exception in update ECMA Action :: " + e.toString());
            flag = INPUT ; 
            return flag;
        }
    
    
    }
    @Override
    public void setSession(Map map) {
        this.sessionmap = map;
    
    }
    public String getEnt_content_type() {
        return ent_content_type;
    }
    public void setEnt_content_type(String ent_content_type) {
        this.ent_content_type = ent_content_type;
    }
    public String getEntry_con_val() {
        return entry_con_val;
    }
    public void setEntry_con_val(String entry_con_val) {
        this.entry_con_val = entry_con_val;
    }
    public String getEntry_con_tag() {
        return entry_con_tag;
    }
    public void setEntry_con_tag(String entry_con_tag) {
        this.entry_con_tag = entry_con_tag;
    }
    public EntryContentTable getEntryContentTable() {
        return entryContentTable;
    }
    public void setEntryContentTable(EntryContentTable entryContentTable) {
        this.entryContentTable = entryContentTable;
    }
    public int getEnt_con_hide() {
        return ent_con_hide;
    }
    public void setEnt_con_hide(int ent_con_hide) {
        this.ent_con_hide = ent_con_hide;
    }
    

    这几乎肯定会成为某个地方的字符编码问题。可能是在提交表格期间;在服务器上处理期间;在持久化到数据库的过程中;或者在数据库列自己的定义中。您需要检查每个步骤期望角色集是什么,以及它们是否正确呈现角色。
    show create table table_name;