Simple and complex jsp (small knowledge), and small knowledge of jsp

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.