---
title: "eclipse 设置模版变量encoding"
author: "wangsong76"
date: "2012-10-01T16:46:02Z"
tags: []
categories: ["开源软件"]
slug: "eclipse-encoding"
draft: false
lastmod: "2012-10-01T16:46:02Z"
id: 1689076
url: "https://wangsong76.iteye.com/blog/1689076"
---

Question：
Charset, encoding of JSP file in eclipse still ISO-8859-1?
Eclipse JSP: incorrect default text file encoding
Solution：

> 
> -vmargs
> -Duser.name=wangsong
> [color=red]-Dfile.encoding=utf-8[/color]
> -Dosgi.requiredJavaVersion=1.5
> -Dhelp.lucene.tokenizer=standard
> -Xms40m
> -Xmx512m
> 

研究了一下午，对于eclipse General Template Variables，关于-vmargs后面到底支持哪些参数，没找到个权威的答案。现在只搞清楚2个变量可以通过配置eclipse.ini搞定

> -Duser.name 设置 ${user}
> -Dfile.encoding 设置 ${encoding}


为什么这么麻烦要搞这个呢？你没碰见这个问题，你不会来看这个文章。我遇到的问题是把eclipse里面能设置encoding的地方都设置了，就是改不到通过templates生成的jsp里面的 ${encoding}。

参考的资料：
<http://stackoverflow.com/questions/9045413/eclipse-jsp-incorrect-default-text-file-encoding>
<http://stackoverflow.com/questions/10460185/charset-encoding-of-jsp-file-in-eclipse-still-iso-8859-1>
<http://network.convergenceservices.in/forum/37-others/1584-setting-up-character-encoding-in-eclipse.html>