question about chinese in struts


Web tier: servlets, JSP, Web frameworks: question about chinese in struts

  1. question about chinese in struts (1 messages)

    i found it's the Strut tag that's _NOT_ handling the utf-8 encoding correctly.I outputted the following on my result jsp after the chinese is inputted:Here, the 'name' is inputted in Chinese and encoded as utf-8:

    <H1> With the Bean Write tag </H1>
    NAME=====><bean:write name="loginForm" property="name"/> <BR>
    password ==><bean:write name="loginForm" property="password"/>
    <H1> With the standard Http request object </H1>
    Name==><%= request.getParameter("name")%><BR>
    password==><%= request.getParameter("password")%><BR>

    With the bean:write tag the name is printed out as ????, while the standard
    request object display the chinese characters correctly.

    Can someone clarify why this is the case? I thought this would not matter
    since reflection is doing the same call using
    request.getParameter("property") to map the input to the form's property.
  2. question about chinese in struts[ Go to top ]

    Here are a couple of things to try:

    Note: I assume that you are using Struts 1.1b3. If not, do so.

    1) In the <controller> element in your struts-config.xml file, make sure that you've set the proper contentType and that locale="true".

    2) Try setting the contentType in the JSP page like this:
    <%@ page contentType="text/html; charset=utf-8" %>

    or as a meta tag in the HTML head:

      <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">

    Just a few ideas.