<a href="branchclient.do?p=add&client_name=河蟹"></a>
branchclient.do的Action时这么处理的。BranchclientAction.javapublic ActionForward execute(ActionMapping mapping , ActionForm form , HttpServletRequest request , HttpServletResponse response)
{
String p = request.getParameter("p");
try
{
         if( "add".equals(p) )
{
return add(mapping, form, request, response);
}
else if( "findbyclientid".equals(p) )
{
return findByClientId(mapping, form, request, response);
}
else
{
return findByClientId(mapping, form, request, response);
}

}
catch( Exception e )
{
e.printStackTrace();
saveMessage(request, "error.operate");
return mapping.findForward("failure");
}public ActionForward add(ActionMapping mapping , ActionForm form , HttpServletRequest request ,  HttpServletResponse response) throws Exception
{
return mapping.findForward("add");
}然后上面那个return mapping.findForward("add");在struts.xml文件里进行跳转
struts.xml文件如下
<action 
name="branchclientForm"
path="/branchclient" 
scope="request"
validate="false"
type="com.dfgg.sms.action.BranchClientAction" >
<forward name="add" path="/BranchClient/BranchClientAdd.jsp" />
<forward name="edit" path="/BranchClient/BranchClientEdit.jsp" />
<forward name="success" path="branchclient.do?s=finddynamic" redirect="true"/>
<forward name="successclient" path="client.do?p=finddynamic" redirect="true"/>
</action>
然后在下面BranchClientAdd.jsp里这样调用最初传的变量client_name=河蟹BranchClientAdd.jsp
<%@ page language="java"  pageEncoding="UTF-8" %>
<html:text property="client_name" readonly="true"  onclick="fnLaunch();"/>页面BranchClientAdd.jsp取到的property="client_name"就是乱码,英文跟数字不是乱码。
如何解决啊

解决方案 »

  1.   

    要写编码过滤器。。在action中打印看下乱码不
      

  2.   

    获取参数之前request.setCharacterEncoding("");
    或者像LS说的写个filter拦截/*设置请求编码
      

  3.   

    有过滤器 
    如下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;

    }
    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;

    }

    protected String selectEncoding(ServletRequest request)
    {

    return(this.encoding);

    }
    }
      

  4.   

    看看页面设置的编码是否一致
    实在不行String str =new String(client_name.getBytes("iso-8859-1"),"utf-8");
    然后传str,就不是乱码了
      

  5.   

    一致 都是UTF-8  
    web.xml如下<filter>
    <filter-name>encodingFilter</filter-name>
    <filter-class>com.dfgg.sms.web.SetCharacterEncodingFilter</filter-class>
            <init-param>   
              <param-name>encoding</param-name>   
              <param-value>UTF-8</param-value>   
            </init-param>
    </filter>
    <filter-mapping>
    <filter-name>encodingFilter</filter-name>
    <url-pattern>/*</url-pattern>
    </filter-mapping>
      

  6.   

    如果是get请求你有没有对url编码呢?
      

  7.   

    首先:
     在页面上.<a href="branchclient.do?p=add&client_name=河蟹"></a>
    改成.<a href="branchclient.do?p=add&client_name=" + encodeURI(encodeURI('河触'))></a>
     在后台.
    java.net.URLDecode("client_name","UTF-8")就不会乱了.
      

  8.   


    把这个写到BranchClientAdd.jspString str =new String((request.getParameter("client_name")).getBytes("iso-8859-1"),"utf-8");
    System.out.println(request.getParameter(str));
    这样转码很不爽啊
      

  9.   


    get  没有编码 什么叫对get进行编码
      

  10.   

    这个不配置服务器的uriencoding=utf-8还是会乱码!
      

  11.   

    下班了,来不及说了。修改tomcat下的server.xml 添加编码
      

  12.   

    1.更改页面编码
    2.更改请求编码
    3.万能的。。   str = new String(str.getByte("iso-8859-1"),"UTF-8")