Simple and complex jsp (small knowledge), and small knowledge of jsp
PageEncoding and contentType attributes in the page tag in JSP
The default value of pageEncoding is the default attribute of ISO-8859-1 contentType: text/html;
Charset = ISO-8859-1
There is a encoding problem here: 1. encoding of the JSP file itself. 2. encoding of pageEncoding. 3
ContentType Encoding
If Chinese characters do not exist, the default encoding is required.
When a JSP file contains Chinese characters, it must be encoded to support Chinese characters such as gbk, gb2312,
UTF-8. If this parameter is not set, Chinese characters in the file are garbled during editing.
In other words, pageEncoding is also the JSP code. Therefore, pageEncoding must be the same as JSP file encoding. Otherwise
Garbled
In fact, pageEncoding should be said to be the encoding of the servlet File In the backend of the jsp server.
For example:
After Entering Chinese in JSP, the compiler (eclipse) will usually prompt whether to save the file as a UTF-8, at this time
Parts are saved as UTF-8 and we also talk about pageEncoding set to GBK, there must be garbled Problem
As for contentType, This is the setting file's mine type.
Let's talk about the JSP file compilation and encoding process.
JSP requires two "encodings". pageEncoding is used in the first stage, UTF-8 to UTF-8 is used in the second stage
Three stages are the web pages that are generated by Tomcat, and contentType is used.
In general, we do not need to set the contentType, because it will change according to the change of pageEncoding by default.
If you have to set it, you have to set the same type as pageEncoding.
No garbled characters
------------------ The following is the code you just learned ----------- (pick)
JavaScript to verify whether the input box is empty:
1. document. getElementById. value. length = 0
2,
<Form name = "free" method = "POST" action = "" onsubmit = "return check ()">
<P align = "center">
<Input type = "text" name = "t1" size = "20">
<Input type = "submit" value = "submit" name = "B1">
</P>
</Form>
Document. free. t1.value. length = 0