freemarker簡單模板如下:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>中文</title>
</head>
<body>
<h1>${name}</h1>
<h2>中文測試</h2>
</body>
</html>
方案如下:
- 設置模板文件本身的屬性:右鍵文件,選擇properties,看text file encoding 選擇UTF-8編碼。
- 在頭部加標簽:<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
- request、response 設置編碼格式為UTF-8。
