import javax.servlet.http.HttpServletResponse;
public class UserServlet exts HttpServlet {
private static final long serialVersionUID = 1L;
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
this.doPost(request, response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String sex = request.getParameter("sex");
String[] bobby = request.getParameterValues("bobby");
System.out.println("性别 :"+new String(sex.getBytes("ISO-8859-1"),"utf-8"));
for (int i = 1; i <= bobby.length; i++) {
System.out.println("快乐喜爱"+i+" :"+new String(bobby[i-1].getBytes("ISO-8859-1"),"utf-8"));
}
}
}


5第五步:利用post体例提交表单 。
<form action="/servlet/userServlet.do" method="post">
快乐喜爱1:<input type="text" name="bobby"><br/>
快乐喜爱2:<input type="text" name="bobby"><br/>
快乐喜爱3:<input type="text" name="bobby"><br/>
快乐喜爱4:<input type="text" name="bobby"><br/>
性别:<input type="text" name="sex"><br/>
<input type="submit" value=https://vvvtt.com/article/"提交">
</form>


6第六部:传输之前利用编码 。
1、js前端编码
encodeURI 方式 编码
decodeURI 方式 解码
2、java后台编码
import java.net.URLDecoder;
import java.net.URLEncoder;
//URLEncoder.encode("乱码","UTF8");编码
//URLDecoder.decode("乱码","UTF-8")解码
以上内容就是servlet获取后台数据乱码处理的内容啦 , 希望对你有所帮助哦!
猜你喜欢
- 金立手机怎么获取ROOT权限呢
- 寻仙手游获取游戏币的方式有哪些?
- 如何快速获取顺丰速发系统配套打印机驱动
- 阿纯竹林游戏怎样免费获取种子
- sqlserver如何获取指定日期当月的最后一天
- 网易云音乐的视频如何后台播放
- 我们使用饿了吗APP怎么获取金币红包呢
- java中怎样获取输入的内容,怎样输出内容呢?
- Servlet类如何映射到URL路径
- dhcp怎么开启
