Primefaces UploadedFileName土耳其字符问题 [英] Primefaces UploadedFileName Turkish character issue
问题描述
我使用PrimeFaces 5.1和p:fileUpload组件上传图片。但我有土耳其chracters的chrachters(例如ıçşğ)。我研究并尝试了很多wat,但我不能成功。
I'm using PrimeFaces 5.1 and p:fileUpload component for uploading images. But I got undefined chrachters for Turkish chracters(for example "ı ç ş ğ"). I researched and tried a lot of wat but I couldn't succeed.I saw this question but not solved my problem. My char encoding filter like below. I also defined filter for this in web.xml file.
public class CharacterEncodingFilter implements Filter {
public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException, ServletException {
req.setCharacterEncoding("ISO-8859-9");
resp.setCharacterEncoding("ISO-8859-9");
chain.doFilter(req, resp);
}
public void init(FilterConfig filterConfig) throws ServletException {
}
public void destroy() {
}}
我的handleFileUpload方法
My handleFileUpload method
public void handleFileUpload(FileUploadEvent event) {
try {
System.out.println(new String(event.getFile().getFileName().getBytes("UTF-8")));
System.out.println(new String(event.getFile().getFileName().getBytes("ISO-8859-9")));
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
到Adsız.png的UTF8和ISO-8859-9字符集。
I'm getting this file names to UTF8 and ISO-8859-9 charsets for "Adsız.png".
Adsñz.png
Adsız.png
Adsız.png
Adsız.png
推荐答案
感谢@BalusC的宝贵意见。我改变为Tomcat编码Cp1254到UTF-8,我确认我使用本机PrimeFaces库并解决了问题。再次感谢@BalusC。
Thank you @BalusC for your valuable comments. I changed to Tomcat encoding Cp1254 to UTF-8 and I confirm that I've used native PrimeFaces library and solved the problem. Thanks @BalusC again.
这篇关于Primefaces UploadedFileName土耳其字符问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!