5 Replies Latest reply on Sep 18, 2013 12:09 PM by kenail2002

    How to set charset for my web application?

    ybxiang.china

      Dear guys,

       

               I am migrating my web application from glassfish 3.1 to jboss7. Now I am suffering charset issues.

       

       

       

      charset setting in my web application:

      (a) bellow meta is added xtml pages (JSF pages)

             <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

      (b) In web.xml, bellow lines are added:


      <context-param>

      <param-name>PARAMETER_ENCODING</param-name>

      <param-value>UTF-8</param-value>

      </context-param>

       

      (c) sun-web.xml

      <?xml version="1.0" encoding="UTF-8"?>

      <!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD GlassFish Application Server 3.0 Servlet 3.0//EN" "http://www.sun.com/software/appserver/dtds/sun-web-app_3_0-0.dtd">

      <sun-web-app error-url="">

        ...

        <parameter-encoding default-charset="UTF-8"/>

      </sun-web-app>

       

      This web application works well in glassfish 3.1.

       

       

      Now, I remove sun-web.xml from this web application and throw this web application into jboss 7( of course, I modified some configuration files, for example persistence.xml).

       

      My  form is:

      <h:form id="form" >

          <h3><h:outputText value="Create"/></h3>

          <h:panelGrid columns="2">

              <h:outputLabel value="Title:" for="title" />

              <h:inputText id="title" value="#{topicCreatingMBean.title}" />

              <h:outputLabel value="Content" for="content" />

              <h:inputTextarea value="#{topicCreatingMBean.content}" id="content" />

              <h:commandButton id="submitButton" value="New" action="#{topicCreatingMBean.create()}" />

          </h:panelGrid>

      </h:form>

       

      Now, I can submit some chinese string into DB, but the title and content in DB are unreadable codes!!! 

      Something Like: ï¼&#140;å¦&#130;ä½&#149;设置è&#135;ªå·±ç&#154;&#132;

       

       

      Do I miss something???

      Is there an equivalent charset setting in jboss-web.xml like sun-web.xml does???

       

      Please help me, thank you very much!