问题描述:
javaweb解决中文乱码问题
解决方案:
public class RegisterServlet extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//以下三行代码解决中文乱码问题
request.setCharacterEncoding("utf-8");
response.setContentType("text/html;charset=utf-8");
response.setCharacterEncoding("utf-8");
//第二种方式:全部一次获取
Map<String, String[]> map = request.getParameterMap();
//遍历集合
map.forEach((s,ss)-> System.out.println(s+"-------------"+ss[0]));