jsp写入access数据乱码
request.setCharacterEncoding("gb2312");Stringname=request.getParameter("name");name=n...
request.setCharacterEncoding("gb2312");
String name =request.getParameter("name");
name=new String(name.getBytes(), "GB2312");
<%@page contentType="text/html"%>
<%@page pageEncoding="gb2312"%>
这类东西我都试过了,不行
读取过之后直接out.println就是乱码
但是直接该mdb文件,用jsp读出来是中文
请大侠指教 展开
String name =request.getParameter("name");
name=new String(name.getBytes(), "GB2312");
<%@page contentType="text/html"%>
<%@page pageEncoding="gb2312"%>
这类东西我都试过了,不行
读取过之后直接out.println就是乱码
但是直接该mdb文件,用jsp读出来是中文
请大侠指教 展开
2个回答
展开全部
这里:name=new String(name.getBytes(), "GB2312");
应该是name=new String(name.getBytes("iso-8859-1"), "GB2312");
另外,你使用name=new String(name.getBytes("iso-8859-1"), "GB2312");了,那么request.setCharacterEncoding("gb2312");就可以省掉不要了。
你先试试,不行的话,在问题里面补充。
应该是name=new String(name.getBytes("iso-8859-1"), "GB2312");
另外,你使用name=new String(name.getBytes("iso-8859-1"), "GB2312");了,那么request.setCharacterEncoding("gb2312");就可以省掉不要了。
你先试试,不行的话,在问题里面补充。
展开全部
见一个拦截器实现接口Filter,需要在web.xml配置,public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws ServletException,IOException{
request.setCharacterEncoding(code);
response.setContentType("text/html;charset=utf-8");
chain.doFilter(request, response);
}
就是类似这样就行
request.setCharacterEncoding(code);
response.setContentType("text/html;charset=utf-8");
chain.doFilter(request, response);
}
就是类似这样就行
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询