不用过滤器如何实现
servlet中
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String key = request.getParameter("key");
DBbean dbbean = new DBbean();
ArrayList list = new ArrayList();
list = dbbean.allStreet(key);
dbbean.dbclose();
request.setAttribute("list",list);
RequestDispatcher rd = request.getRequestDispatcher("/index/page2.jsp?key1=2");
rd.forward(request, response);
现在是不想使用过滤器,但是rd跳转后界面出现乱码,问如何实现
------解决方案--------------------response.setContentType("text/html");
PrintWriter out = response.getWriter();
String key = request.getParameter("key");
DBbean dbbean = new DBbean();
ArrayList list = new ArrayList();
list = dbbean.allStreet(key);
dbbean.dbclose();
request.setAttribute("list",list);
RequestDispatcher rd = request.getRequestDispatcher("/index/page2.jsp?key1=2");
rd.forward(request, response);
_____________________________________________________________________________
在第一行的response.setContentType();的参数里加上中文编码格式(charSet="GBK")试一下
------解决方案--------------------response.setContentType("text/html;charset=gb2312");
request.setC(c开头的具体忘记了不好意思)XXXXXX("gb2312");
这个样子应该没问题了还有如果是get传过来参数 那么就要挨个解了