Spring project 奇數中文 一箇中文 聲明 報錯 編碼問題 不直接支持 UTF-8

Spring roo project中 異常:

 

Multiple markers at this line
    - The local variable a is never read
    - String literal is not properly closed by a double-
     quote

 

Spring Roo 目前還不直接支持UTF8,只支持西歐字體,用native2ascii轉,可以使用maven的plugin了。

下面是配置例子:

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
  <execution>
   <id>compile</id>
   <phase>compile</phase>
   <configuration>
    <tasks>
     <native2ascii
       encoding="UTF-8"
       src="src/main/webapp/WEB-INF/i18n"
       dest="target/${name}-${version}/WEB-INF/i18n"
       includes="*_zh.properties"/>
    </tasks>
   </configuration>
   <goals>
    <goal>run</goal>
   </goals>
  </execution>
</executions>
<dependencies>
  <dependency>
   <groupId>ant</groupId>
   <artifactId>ant-nodeps</artifactId>
   <version>1.6.5</version>
  </dependency>
  <dependency>
   <groupId>com.sun</groupId>
   <artifactId>tools</artifactId>
   <version>1.5.0</version>
   <scope>system</scope>
   <systemPath>${java.home}/../lib/tools.jar</systemPath>
  </dependency>
</dependencies>
</plugin>

 

例如:spring roo project中 :

String hello = "你";

當遇到奇數個漢字的聲明的時候會報錯誤。

 

處理方法如上!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章