STRUTS插中文数据到SQLSERVER数据库中怎么就成乱码了呢?请知道的朋友指点一下!听别人说要转换编码,但具体怎么做不清楚。希望能给个具体点的建议,谢谢!
解决方案 »
- JSP中验证用户登录时出现空指针异常问题
- 从一个frame里指定另一个frame里的frame的src,如何实现?
- 请大虾们用通熟的语言讲解一下面向对象.
- JSP页面如何完成可选择跳过页面打印!
- myeclipse如何打包成jar?
- 出错提示!
- jsp中的indeOf函数 在jstl怎么实现
- 怎样获取年月日显示的下拉菜单 所显示的日期 最后使其成为一个Date类型的数据?
- 如何解决页面过期的问题?
- 急!急!关于Unable to compile class for JSPNote: sun.tools.javac.Main has been deprecated的问题
- servlet获得response的数据
- 关于使用httpclient登录的问题
在action 里得到前台提交的字符串用
String name=(String)request.getParameter("textfield");
在得到以后转换一下
try{
name=new String(name.getBytes("ISO8859_1"), "gb2312");
}catch(Exception e){
}
import java.io.UnsupportedEncodingException;import org.apache.struts.action.RequestProcessor;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class MyRequestProcessor extends RequestProcessor {
protected boolean processPreprocess(HttpServletRequest request,
HttpServletResponse response){
try {
request.setCharacterEncoding("gb2312");
} catch (UnsupportedEncodingException e) {
System.out.print("字符集设置失败");
}
return true;
}
}
共享一下,呵呵!