使用的是ssh框架。页面上的汉字都正常显示。但传到action中就乱码了。过滤器也使用了。<filter>
<filter-name>setCharacterEncoding</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param> 
</filter>
<filter-mapping>
<filter-name>setCharacterEncoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
页面上:<%@ page language="java" contentType="text/html;charset=gbk"
pageEncoding="gbk"%>
<%@ taglib prefix="s" uri="/struts-tags"%><body>
<s:form action="BusinessAction" theme="simple" method="POST"> 
<s:actionerror/> 
<s:fielderror></s:fielderror><br>
 <s:if test="null == contact">
            Add Contact
        </s:if>
        <s:else>
            Edit Contact
        </s:else>
<div>
操作action:<select name="action">
<option value="getBusinessList">查询</option>
<option value="addBusiness">添加addBusiness</option>
<option value="updateBusiness">修改updateBusiness</option>
<option value="deleteBusiness">删除deleteBusiness</option>
</select>
      ID:<s:textfield name="business.businessId"></s:textfield>在删除和修改时请填写
   <br>
        名称<s:textfield name="business.name"></s:textfield>
   <br>
   ipaddress:<s:textfield name="business.ipaddress"></s:textfield><br>
   port:<s:textfield name="business.port"></s:textfield><br>
   isSt是否:<select name="business.st">
    <option value="true">是</option>
    <option value="false">否</option>
   </select><br>
 
   <s:submit value="提交"></s:submit>
   <s:reset value="重置"></s:reset>
  
</div>
</s:form>
</body>

解决方案 »

  1.   

    要统一,不要一会儿utf-8,一会儿gbk
      

  2.   

    <%@ page language="java" contentType="text/html;charset=gbk"
    pageEncoding="gbk"%>->
    <%@ page language="java" contentType="text/html;charset=UTF-8"
    pageEncoding="UTF-8"%>
    典型的编码不统一!!!!web乱码
    http://blog.csdn.net/crazylaa/archive/2009/12/24/5066784.aspx
      

  3.   

    过滤器用了utf-8了
    页面上 都用utf-8
    统一编码
      

  4.   

    我改过了,环视乱码。。
    <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
    <%@ taglib prefix="s" uri="/struts-tags"%>
    <%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
    + request.getServerName() + ":" + request.getServerPort()
    + path + "/";
    %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <base href="<%=basePath%>"> <title>My JSP 'middle.jsp' starting page</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">

    <style>
    .font{
    font-family: "宋体";
    }
    </style>
    </head>
    <body>
    <s:form action="BusinessAction" theme="simple" method="POST"> 
    <s:actionerror/> 
    <s:fielderror></s:fielderror><br>
     <s:if test="null == contact">
                Add Contact
            </s:if>
            <s:else>
                Edit Contact
            </s:else>
    <div>
    操作action:<select name="action">
    <option value="getBusinessList">查询</option>
    <option value="addBusiness">添加addBusiness</option>
    <option value="updateBusiness">修改updateBusiness</option>
    <option value="deleteBusiness">删除deleteBusiness</option>
    </select>
          ID:<s:textfield name="business.businessId"></s:textfield>在删除和修改时请填写
       <br>
            名称<s:textfield name="business.name"></s:textfield>
       <br>
       ipaddress:<s:textfield name="business.ipaddress"></s:textfield><br>
       port:<s:textfield name="business.port"></s:textfield><br>
       isSt是否:<select name="business.st">
        <option value="true">是</option>
        <option value="false">否</option>
       </select><br>
     
       <s:submit value="提交"></s:submit>
       <s:reset value="重置"></s:reset>
    </div>
    </s:form>
    </body>
    </html>
      

  5.   

    第一步,把页面编码改成utf-8
    第二步,在过虑器里打印一下数据看看,过虑器有没有起作用,或者设断点也行
    如果进到action里面是乱码,要么是你过虑器代码不对,要么是过虑器没有起作用,你的配置有问题
    如果你在页面上使用GBK显示正常,那么就是你的过虑器有问题了
    好好检查一下