html中
select name="颜"
option value="红">红</option
servlet中String color=request.getParameter("颜");
response.setContentType("utf-8");
PrintWriter pw =response.getWriter();
pw.println(color);
结果:The selected color is: null
并不是给参数设置中文出现乱码,而是给需传递的属性命名时使用了中文,无法传递。
尝试过将html另存为utf-8,unicode,没效果。
在页面为ansi格式的时候,因为用的get方式,可以看到明文传递值是%D1%D5,将servlet改为getParameter("%D1%D5"),getParameter("D1D5")也都无效。
平时也不会用中文做传递值名,只是无意中发现这种情况,想请问下原因和处理方法。