猿问

如何使用 XPAGES DesignerFacesServlet 显示泰语字母

我尝试创建 XSP Servlet 并希望在我的 Web 应用程序中完全支持泰语(和/或其他亚洲/阿拉伯字母)。


此脚本是来自https://frostillic.us/blog/posts/159496067A27FD3585257A70005E7BC1的自定义版本


环境:Domino 9.0.1 FP6,Windows Server 2008


package com.testing.servlet;


import java.io.*;

import java.util.*;

import com.ibm.commons.util.StringUtil;

import com.ibm.xsp.webapp.DesignerFacesServlet;

import javax.faces.context.FacesContext;

import javax.servlet.*;

import javax.servlet.http.*;

import lotus.domino.*;



public class Testing extends DesignerFacesServlet {


    //Session

    private static Session getCurrentSession(FacesContext context) {

        return (Session) context.getApplication().getVariableResolver()

                .resolveVariable(context, "session");

    }


    private void incinerate(Object... dominoObjects) {

        for (Object dominoObject : dominoObjects) {

            if (null != dominoObject) {

                if (dominoObject instanceof Base) {

                    try {

                        ((Base)dominoObject).recycle();

                    } catch (NotesException e) {

                        System.out.println("[FAILED TO RECYCLE]");

                        e.printStackTrace();

                    }

                }

            }

        }

    }



    public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException {

        HttpServletRequest req = (HttpServletRequest)servletRequest;

        HttpServletResponse res = (HttpServletResponse)servletResponse;

        ServletOutputStream out = res.getOutputStream();

        FacesContext facesContext = this.getFacesContext(req, res);

        Session session = null;

        Database database = null;

        View view = null;

        Document doc = null;

            }

        }

    }

}

结果


start

Counter: 5

???????????? // thai letter display as ????

done

如何显示泰文而不是????


慕勒3428872
浏览 80回答 1
1回答

Smart猫小萌

在处理挪威字符时,我遇到了类似的问题。能够通过切换到 aPrintWriter而不是来修复它ServletOutputStream:HttpServletResponse res = (HttpServletResponse) servletResponse;HttpServletRequest req = (HttpServletRequest) servletRequest;res.setContentType("application/json; charset=UTF-8;");//use a PrintWriter here, since we also have to deal with UTF-8 charactersPrintWriter out = res.getWriter();刚刚对泰语和阿拉伯语进行了快速测试,这似乎有效。
随时随地看视频慕课网APP

相关分类

Java
我要回答