I encountered a very strange problem today. Look at the following code: SimpleDateFormat dateFormat = new SimpleDateFormat Copy code The code is as follows: teFormat("yyyy year MM month dd day E "); String date = dateFormat.format(new Date()); The original intention was to print out XXXX year XX month XX day week X The problem is in the following code. When I want to get the formatted data, I can only get "XXXX year XX month XX day" when using the value= method, but I can't get the "week X" behind it. Copy code The code is as follows:<td align="left"> <label> <input type="text" value=<%=date%> disabled /> </label> </td> ① Later, I thought that it might be an HTML escape problem, so I removed all the spaces in "yyyy年MM月dd日E", and the result was that the value could be obtained normally or changed to "yyyy年MM月dd日-E" ② Another method is to use escape characters to replace the contents of the string to be displayed one by one. Copy code The code is as follows:<% String result = ""; for (int i = 0; i < date.length(); i++) { switch (date.charAt(i)) { case '<': result += "<"; break; case '>': result += ">"; break; case '&': result += "&"; break; case '"': result += "\""; break; case '\'': result += "'"; break; case ' ': result += " "; break; default: result += date.charAt(i); } } %> The references are as follows : HTML source code to display the result description < < less than sign or display mark > > Greater than sign or display mark & & can be used to display other special characters " " quotation mark ® ® Registered © © Copyright ™ ™ Trademark   Half blank space   A blank space No breaking whitespace |
<<: Display flex arrangement in CSS (layout tool)
>>: Solution to MySQL 8.0 cannot start 3534
Table of contents 1 What is function currying? 2 ...
HTML meta tag HTML meta tags can be used to provi...
Sometimes the page is very long and needs an arro...
ElasticSearch cluster supports動態請求的方式and靜態配置文件to ...
String extraction without delimiters Question Req...
Table of contents 1. Deconstruction Tips 2. Digit...
Table of contents 1. Control the display and hidi...
Reverse Proxy Reverse proxy refers to receiving t...
Starting from IE 8, IE added a compatibility mode,...
In the previous article, we played with timeouts ...
1. Write a Mysql link setting page first package ...
Use indexes to speed up queries 1. Introduction I...
Table of contents cause: go through: 1. Construct...
Closures are one of the traditional features of p...
1. What is phantom reading? In a transaction, aft...