HttpServletRequest的getParameter()的坑及解决
package servlet;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet implementation class TestServlet
*/
@WebServlet("/test")
public class TestServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String name = request.getParameter("name");
System.out.println("name:" + name);
response.getWriter().append("Served at: ").append(request.getContextPath());
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//request.setCharacterEncoding 只能解决post 乱码问题
request.setCharacterEncoding("utf-8");
doGet(request, response);
}
}
相关文章
- HttpServletRequest的getParameter()的坑及解决
- 浏览器查看网页提示危险内容不使用安全HTTPS连接传送该怎办?
- HttpFile.dll
- Socks2HTTP(代理服务器协议转换助手) V0.93 免费汉化安装版
- C#使用HttpClient对大文件进行断点上传和下载
- Android Https证书过期的两种解决方案
- 451错误是什么意思?HTTP网页错误代码403和451有什么区别?
- Storm Sniffer(HTTP抓包网络调试利器)v2.1.9 苹果手机版
- AndroidHttpClient使用Cookie应用分析
- C/C++通过HTTP实现文件上传与下载的示例详解