在Java中处理法语字符 [英] Handle French Characters in Java

查看:201
本文介绍了在Java中处理法语字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个页面,我搜索一个术语,它显示完美。无论什么字符类型。



现在,当我在JSP中有几个复选框,我检查并提交。在这些复选框中,我有一个框名称,如 ABCFarmacéuticaCorporation



当我点击提交按钮时,我正在调用一个函数,并将所有参数设置为一个表单,并提交该表单。 (我测试在提交之前为特殊字符显示提醒,并且显示良好)。



现在来到Java端,我使用Springs Frame工作。当我在控制器中打印该术语时,它显示为 ABCFarmacéutica Corporation



请帮助。
提前感谢



编辑:



请尝试此示例示例

  import java.net。*; 
class sample {
public static void main(String [] args){
try {
String aaa =ABCFarmacéuticaCorporation;
String bbb =ABCFarmacéutica Corporation;

aaa = URLEncoder.encode(aaa,UTF-8);
bbb = URLDecoder.decode(bbb,UTF-8);

System.out.println(aaa+ aaa);
System.out.println(bbb+ bbb);

} catch(Exception e){
System.out.println(e);
}
}
}

我正在获得输出,

  aaa PiSA + Farmac%C3%A9utica + Mexicana + Corporativo 
bbb PiSAFarmacéuticaMexicana Corporativo

尝试打印 string aaa

解决方案

这是一个编码问题,Ã这是UTF-8文本解释为ISO-Latin-1(或其表兄弟之一)。



确保顶部的JSP页面显示它使用UTF-8编码。


I Have a Page where I search for a term and it is displaying perfect. Whatever character type it is.

Now when I have few checkboxes in JSP and I check it and submit. In these checkboxes I have one box name like ABC Farmacéutica Corporation.

When I click on submit button, I am calling a function and will set all parameters to a form and will submit that form. (I tested putting alert for the special character display before submit and it is displaying good).

Now, coming to the Java end, I use Springs Frame work. When I print the term in controller, then it is displayed like ABC Farmacéutica Corporation.

Please help... Thanks in advance.

EDIT :

Please try this sample Example

import java.net.*;
class sample{
    public static void main(String[] args){
        try{
            String aaa = "ABC Farmacéutica Corporation";
            String bbb = "ABC Farmacéutica Corporation";

            aaa = URLEncoder.encode(aaa, "UTF-8");
            bbb = URLDecoder.decode(bbb, "UTF-8");

            System.out.println("aaa   "+aaa);
            System.out.println("bbb   "+bbb);

        }catch(Exception e){
            System.out.println(e);      
        }
    }
}

I am getting output as,

aaa   PiSA+Farmac%C3%A9utica+Mexicana+Corporativo
bbb   PiSA Farmacéutica Mexicana Corporativo

Try to print the string aaa as it is.

解决方案

This is an encoding problem, and the à clearly identify that this is UTF-8 text interpreted as ISO-Latin-1 (or one of its cousins).

Ensure that your JSP-page at the top show that it uses UTF-8 encoding.

这篇关于在Java中处理法语字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆