日期:2014-05-17  浏览次数:20670 次

SSH 中文乱码
XML code

    <filter>
        <filter-name>encodingFilter</filter-name>
        <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
        <init-param>
            <param-name>encoding</param-name>
            <param-value>GBK</param-value>
        </init-param>
    </filter>

    <filter-mapping>
        <filter-name>encodingFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>



Java code

<%@ page language="java" import="java.util.*" pageEncoding="GBK"%>

    <form method="post" action="useraction!add">
        username:<input type="text" name="user.name"><br/>
        password:<input type="password" name="user.password"><br/>
        <input type="submit" value="提交"/> 
    </form>



在useraction中
system.out.println(user.getName());

乱码的....
请问怎么解决啊?

------解决方案--------------------
换成UTF-8看看