


Sample code sharing on the difference between HTML submission methods post and get
The difference between post and get in HTML submission methods (experiment)
1. The difference between post and get
Get submission, the submitted information is displayed in the address bar.
Post submission, the submitted information is not displayed in the address bar, but is displayed in the message body.
2. Client code
nbsp;html><title>Form.html</title> <meta> <meta> <meta> <!--<link rel="stylesheet" type="text/css" href="./styles.css">--> <!--提交方式:get提交。地址栏:http://localhost:9891/?user=abc&psw=123&repsw=123&sex=nan&tech=java&tech=html&country=cn GET /?user=abc&psw=123&repsw=123&sex=nan&tech=java&tech=html&country=cn HTTP/1.1 Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */* Accept-Language: zh-cn,zu;q=0.5 Accept-Encoding: gzip, deflate User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; InfoPath.2) Host: localhost:9891 Connection: Keep-Alive 提交方式:POST地址栏:http://localhost:9891/POST / HTTP/1.1 Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */* Accept-Language: zh-cn,zu;q=0.5 Content-Type: application/x-www-form-urlencoded Accept-Encoding: gzip, deflate User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; InfoPath.2) Host: localhost:9891 Content-Length: 68 Connection: Keep-Alive Cache-Control: no-cacheuser=hahah&psw=8989&repsw=8989&sex=nv&tech=html&tech=css&country=usa GET提交和POST提交的区别? 1, get提交,提交的信息都显示在地址栏中。 post提交,提交的信息不显示地址栏中。 2, get提交,对于敏感的数据信息不安全。 post提交,对于敏感信息安全。 3, get提交,对于大数据不行,因为地址栏存储体积有限。 post提交,可以提交大体积数据。 4, get提交,将信息封装到了请求消息的请求行中。 post提交,将信息封装到了请求体中。 在服务端的一个区别。 如果出现将中文提交到tomcat服务器,服务器默认会用iso8859-1进行解码会出现乱码, 通过iso8859-1进行编码,在用指定的中文码表解码。即可。 这种方式对get提交和post提交都有效。 但是对于post提交方式提交的中文,还有另一种解决办法,就是直接使用服务端一个对象 request对象的setCharacterEncoding方法直接设置指定的中文码表就可以将中文数据解析出来。 这个方法只对请求体中的数据进行解码。 综上所述:表单提交,建议使用post。 和服务端交互的三种方式: 1,地址栏输入url地址。get 2,超链接。 get 3,表单。 get 和 post 如果在客户端进行增强型的校验(只要有一个组件内容是错误,是无法继续提交的。只有全对才可以提交) 问,服务端收到数据后,还需要校验吗? 需要,为了安全性。 为了信息安全,也为了客户端那边不要乱提交数据,客户端和服务端都需要做校验。 如果服务端做了增强型的校验,客户端还需要校验吗? 需要,因为要提高用户的上网体验效果,减轻服务器端的压力。 --> 表单格式化 <br> <!-- action里面的http协议不能忘记 -->
3. Server code
RegServer.java
/** * */ package cn.itcast.server; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.net.ServerSocket; import java.net.Socket; /** * @author Fry * */ public class RegServer { /** * @param args * @throws Exception */ public static void main(String[] args) throws Exception { ServerSocket ss = new ServerSocket(9891);//新建服务端端口 Socket s = ss.accept();//端口监听 //输出服务器主机地址 ans:0:0:0:0:0:0:0:1 System.out.println(s.getInetAddress().getHostAddress()); InputStream in = s.getInputStream();//字节输入流,用来接收客户端消息 byte[] buf = new byte[1024];//1024字节的缓存 int len = in.read(buf);//将收到的消息读到buf中 //输出接收到的页面消息 包括消息行 消息头 消息体 System.out.println(new String(buf,0,len)); //字符输出,用来存储发送给客户端的消息 PrintWriter out = new PrintWriter(s.getOutputStream(),true); //客户端接收到的消息 out.println("<font color='green' size='7'>注册成功</font>"); //关闭端口 s.close(); ss.close(); } }
4. Result
The above is the detailed content of Sample code sharing on the difference between HTML submission methods post and get. For more information, please follow other related articles on the PHP Chinese website!

HTML is a language used to build web pages, defining web page structure and content through tags and attributes. 1) HTML organizes document structure through tags, such as,. 2) The browser parses HTML to build the DOM and renders the web page. 3) New features of HTML5, such as, enhance multimedia functions. 4) Common errors include unclosed labels and unquoted attribute values. 5) Optimization suggestions include using semantic tags and reducing file size.

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

The role of HTML is to define the structure and content of a web page through tags and attributes. 1. HTML organizes content through tags such as , making it easy to read and understand. 2. Use semantic tags such as, etc. to enhance accessibility and SEO. 3. Optimizing HTML code can improve web page loading speed and user experience.

HTMLisaspecifictypeofcodefocusedonstructuringwebcontent,while"code"broadlyincludeslanguageslikeJavaScriptandPythonforfunctionality.1)HTMLdefineswebpagestructureusingtags.2)"Code"encompassesawiderrangeoflanguagesforlogicandinteract

HTML, CSS and JavaScript are the three pillars of web development. 1. HTML defines the web page structure and uses tags such as, etc. 2. CSS controls the web page style, using selectors and attributes such as color, font-size, etc. 3. JavaScript realizes dynamic effects and interaction, through event monitoring and DOM operations.

HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

HTML is suitable for beginners because it is simple and easy to learn and can quickly see results. 1) The learning curve of HTML is smooth and easy to get started. 2) Just master the basic tags to start creating web pages. 3) High flexibility and can be used in combination with CSS and JavaScript. 4) Rich learning resources and modern tools support the learning process.

AnexampleofastartingtaginHTMLis,whichbeginsaparagraph.StartingtagsareessentialinHTMLastheyinitiateelements,definetheirtypes,andarecrucialforstructuringwebpagesandconstructingtheDOM.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

SublimeText3 Linux new version
SublimeText3 Linux latest version

SublimeText3 Chinese version
Chinese version, very easy to use