red phoenix wrote:
I want to get a value from a JSP in Action,like follows:
/*jsp*/
<%@ page contentType="text/html;charset=gb2312" %>
<html:text property="ex"/>
.....

And I input a Chinese Word in ex area,then I get the ex value from a
Action,like follows:
/*Action*/
public ActionForward execute(ActionMapping mapping,ActionForm
form,HttpServletRequest request,HttpServletResponse response) throws
Exception {
  request.setCharacterEncoding("gb2312");
  String ex=request.getParameter("ex");
....

But I find ex don't show propertly,it should show right Chinese word,but it
shows ???????í?±,I use DynaActionForm,like follows:
<form-bean
  name="tt"
 type="org.apache.struts.action.DynaActionForm">
  form-property
  name="ex"
  type="java.lang.String"/>
...

Why struts don't show propertly? How to show Chinese Word in Struts Action?

The call to setCharacterEncoding() looks suspicious to me; I don't think that should be necessary. You have the character encoding declared in the JSP page directive, which is good; you may also need to add a meta-equiv content type tag to your page (in the HTML HEAD section) to help the browser determine the character encoding to use.

Also be wary of displaying non-ASCII string values with e.g. System.out.println(); the console output may be misleading if it's using the wrong character encoding. Test your 'ex' variable's value against a known-good string constant to verify it rather than relying on printing it.

HTH,

L.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to