Incomplete solution for using input type=text value=str

Incomplete solution for using input type=text value=str
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 += "&nbsp;";
break;
default:
result += date.charAt(i);
}
}
%>

The references are as follows :
HTML source code to display the result description
&lt; < less than sign or display mark
&gt; > Greater than sign or display mark
&amp; & can be used to display other special characters
&quot; " quotation mark
&reg; ® Registered
&copy; © Copyright
&trade; ™ Trademark
&ensp; Half blank space
&emsp; A blank space
&nbsp; No breaking whitespace

<<:  Display flex arrangement in CSS (layout tool)

>>:  Solution to MySQL 8.0 cannot start 3534

Recommend

JavaScript Function Currying

Table of contents 1 What is function currying? 2 ...

Examples of some usage tips for META tags in HTML

HTML meta tag HTML meta tags can be used to provi...

Detailed tutorial for installing ElasticSearch:7.8.0 cluster with docker

ElasticSearch cluster supports動態請求的方式and靜態配置文件to ...

MySQL string splitting example (string extraction without separator)

String extraction without delimiters Question Req...

Six weird and useful things about JavaScript

Table of contents 1. Deconstruction Tips 2. Digit...

An article to help you understand jQuery animation

Table of contents 1. Control the display and hidi...

Nginx reverse proxy and load balancing practice

Reverse Proxy Reverse proxy refers to receiving t...

Tips on disabling IE8 and IE9's compatibility view mode using HTML

Starting from IE 8, IE added a compatibility mode,...

Play with the connect function with timeout in Linux

In the previous article, we played with timeouts ...

IDEA complete code to connect to MySQL database and perform query operations

1. Write a Mysql link setting page first package ...

MySql index improves query speed common methods code examples

Use indexes to speed up queries 1. Introduction I...

Detailed explanation of this reference in React

Table of contents cause: go through: 1. Construct...

Detailed explanation of JavaScript closure issues

Closures are one of the traditional features of p...

Detailed explanation of how MySQL solves phantom reads

1. What is phantom reading? In a transaction, aft...