zoukankan      html  css  js  c++  java
  • get和post的区别与乱码问题解决

    ★ get和post的区别:
        1.get请求通过url地址发送请求参数,可以在地址栏上直接显示
        2.post请求通过请求体发送请求参数,不会再地址栏上显示
        3.get在地址栏显示请求参数安全性低,而post请求要好一些
        4.get请求通过地址栏发送请求参数,长度有限制,最大发送255个字符。
            post请求通过请求体发送请求参数,大小没有限制。
        5.一般开发中提交表单时均使用post请求,get请求一般不用
     
    ********************************* **************************解决请求时乱码,将字符集统一,推荐utf-8******************************************************************
    ★ 在Tomcat服务器中server.xml 添加()
            <Connector URIEncoding="utf-8" port="8080" protocol="HTTP/1.1"
                   connectionTimeout="20000"
                   redirectPort="8443" />
     
     
     ★  编码:
        protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
     
            response.setContentType("text/html;charset=utf-8");
            process(request,response);
     
        }
     
        protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
     
            request.setCharacterEncoding("utf-8");
            process(request,response);
     
        }
     
        public void process(HttpServletRequest request, HttpServletResponse response)
                          throws ServletException, IOException {
     
        }
     
     
     
    - 转发的路径由服务器解析,设置绝对路径时不需要加项目名
     - 重定向的路径由浏览器解析,设置绝对路径时需要加上项目名
    请求的转发:
        request.getRequestDispatcher("/pages/manager/**.jsp").forward(request, response);
    请求的重定向:
        response.sendRedirect(request.getContextPath()+"/manager/***?method=find");
  • 相关阅读:
    ubuntu中,终端命令行快速打开html文件方法
    Python清空文本内容的两种方法
    科大教学日历
    MJ瀑布流学习笔记
    iOS搜索框
    异步IO
    yield
    ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
    15个常用的javaScript正则表达式
    Linux 升级 Python 至 3.x
  • 原文地址:https://www.cnblogs.com/libingbin/p/5955203.html
Copyright © 2011-2022 走看看