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
1. Prepare in Advance For your convenience, I cre...
First, let’s look at the GIF operation: Case 1: S...
Today I learned a new CSS special effect, the wav...
Achieve resultsImplementation Code html <div&g...
Table of contents Overview Static type checking C...
This article example shares the specific code of ...
Data integrity is divided into: entity integrity,...
Recently, there have been many database-related o...
Preface This article aims to explain the most bor...
System: Ubuntu 16.04LTS 1\Download mysql-5.7.18-l...
This article shares the specific code of JavaScri...
<br />Original URL: http://www.lxdong.com/po...
Download tutorial of mysql-connector-java.jar pac...
React originated as an internal project at Facebo...
How to implement text icons through CSS /*icon st...