页面设置为<%@ page contentType="text/html;charset=gb2312"%>
如果页面中没有中文字符则在提交Action中用:
new String(ba_lubeForm.getClname().getBytes("ISO-8859-1"),"gb2312")可以将转换为中文字
但是,页面中包含中文字符如:
<td valign="left" width=33%>
名称:<input type="text" name="clname" size="15">
</td>
则在提交Action中还是乱码望高手指点

解决方案 »

  1.   

    换成<%@ page language="java" pageEncoding="GBK"%> 试试。。在eclipse是可以显示中文的。不知道你用哪个开发工具
      

  2.   

    调试的时候在Action中就是乱码
      

  3.   

    package com.future.petrol.struts.filters;import java.io.IOException;import javax.servlet.Filter;
    import javax.servlet.FilterChain;
    import javax.servlet.FilterConfig;
    import javax.servlet.ServletException;
    import javax.servlet.ServletRequest;
    import javax.servlet.ServletResponse;public class SetCharacterEncodingFilter implements Filter {
    protected String encoding = null; protected FilterConfig filterConfig = null; protected boolean ignore = true; public void destroy() {
    this.encoding = null;
    this.filterConfig = null;
    } protected String selectEncoding(ServletRequest request) {
    return (this.encoding);
    } public void doFilter(ServletRequest request, ServletResponse response,
    FilterChain chain) throws IOException, ServletException {
    if (ignore || (request.getCharacterEncoding() == null)) {
    String encoding = selectEncoding(request);
    if (encoding != null)
    request.setCharacterEncoding(encoding);
    } chain.doFilter(request, response);
    } public void init(FilterConfig filterConfig) throws ServletException {
    this.filterConfig = filterConfig;
    this.encoding = filterConfig.getInitParameter("encoding");
    String value = filterConfig.getInitParameter("ignore");
    if (value == null)
    this.ignore = true;
    else if (value.equalsIgnoreCase("true"))
    this.ignore = true;
    else if (value.equalsIgnoreCase("yes"))
    this.ignore = true;
    else
    this.ignore = false; }}
      

  4.   

    在“控制面扳”中,把“区域”设置为“英语(美国)”. 
    在JSP页面中加入: 
    如果还不行正常显示,则还要进行下面的转换: 
    如:name=new  String(name.getBytes("ISO-8859-1"),"GBK"); 
    就不会出现中文问题了。 
      

  5.   

    或者直接在JSP页面加上:  request.setCharacterEncoding("GB2312");