你在你的servlet里面可以打印一下你从jsp获取到的那些数据,
如果是乱码的话你可以这样
String getName=new String(request.getParameter("Name").getBytes("iso8859_1"),"gbk");
一般tomcat的字符集是iso8859_1的,所以你的数据经过tomcat提交过来以后,就变成了iso8859_1了,所以这个时候需要你转换一下了,你可以试试,^_^
如果是乱码的话你可以这样
String getName=new String(request.getParameter("Name").getBytes("iso8859_1"),"gbk");
一般tomcat的字符集是iso8859_1的,所以你的数据经过tomcat提交过来以后,就变成了iso8859_1了,所以这个时候需要你转换一下了,你可以试试,^_^
import java.io.PrintStream;
import java.net.URLEncoder;
import sun.io.CharToByteConverter;
import sun.io.CharToByteUTF8;public class MyString
{ public MyString()
{
} public static boolean isEmpty(String _string)
{
return _string == null || _string.trim().length() == 0;
} public static boolean isEmptyStr(String _string)
{
return _string == null || _string.trim().length() == 0;
} public static String showNull(String p_sValue)
{
return showNull(p_sValue, "");
} public static String showNull(String _sValue, String _sReplaceIfNull)
{
return _sValue != null ? _sValue : _sReplaceIfNull;
} public static String getStr(String _strSrc)
{
return getStr(_strSrc, ENCODING_DEFAULT);
} public static String getStr(String _strSrc, boolean _bPostMethod)
{
return getStr(_strSrc, _bPostMethod ? ENCODING_DEFAULT : GET_ENCODING_DEFAULT);
} public static String getStr(String _strSrc, String _encoding)
{
if(_encoding == null)
return _strSrc;
String s1;
try
{
byte bytes[] = _strSrc.getBytes(_encoding);
String s = new String(bytes);
return s;
}
catch(Exception ex)
{
s1 = _strSrc;
}
return s1;
} public static String toISO_8859(String _strSrc)
{
if(_strSrc == null)
return null;
try
{
String s = new String(_strSrc.getBytes(), "ISO-8859-1");
return s;
}
catch(Exception ex)
{
String s1 = _strSrc;
return s1;
}
} public static String toUnicode(String _strSrc)
{
return toISO_8859(_strSrc);
}
}